A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Variable scope

  1. #1
    Member
    Join Date
    Sep 2000
    Posts
    44
    If I have a 10 frame movie and in frame four I say:
    name = “Bob” Is it correct to say that when that movie is loaded for the first time frames 1-3 will not have “Bob” but anytime after frame 4 has played frames 1-3 and all other frames will have the value of “Bob”? Or dose it make more sense to think of the variable as having the value and existing outside of the movie?

    Maybe a better way to ask is:
    What is the scope of variables in Flash?
    If you jump back to frame one, is it still Bob?
    What If I didn't want frames 1-3 to be Bob, could I kill
    Bob in the last frame? How?

    Thanks

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    103
    a Variable is a Variable only after you have announce on him!!!!!
    After your announce set variavle :var_name = var_value)
    you can do what ever you want with it.
    Now, if you have announce on a Variable in frame 3 , you will not be able to use it in frames 1 or 2!!!
    But, after u have announce on it , you can call it as many times you want, from any place you want (even from out of of flash!!!)
    At last, if u want to "kill" a Variable, simply give him a new value, or give him a null value.

    Hope it helps
    ND

  3. #3
    Member
    Join Date
    Sep 2000
    Posts
    44
    At last, if u want to "kill" a Variable, simply give him a new value, or give him a null value.

    Thanks for the feedback!

    That’s interesting – if variables exist independently from the movies they were declared in , then I should be able to reference them from another movie.I would like to change the value of a variable started in firstMovie.swf from
    secondMovie.swf but I don’t know the syntax.

    How would I reference it and change it to null?

    Thanks again for the help


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center