set and get variables throughout moive - actionscript 3

Posted by ed209 on Stack Overflow See other posts from Stack Overflow or by ed209
Published on 2009-09-17T10:13:02Z Indexed on 2010/03/14 9:05 UTC
Read the original article Hit count: 243

Filed under:
|
|

I need to set various variables depending on what a user clicks. Those variables then need to be accessed by other movieclips.

The problem is that at the time of clicking, those "other movieclips" don't exist on the timeline yet.

What I have done is assign the variable to the parent movieclip, although I guess I could just as easily set them to the root. Then I would grab that value when the relevant clip is initiated.

// set - works
MovieClip(parent).aMovieClip.someVariable = myVal;

// get? - doesn't work
getVar = MovieClip(parent).aMovieClip.someVariable;

the above doesn't work - what is the correct way to get that value whenever I need it. I guess it's a case of getting and setting global variables

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flash