Skip to main content
FlashTapper
Inspiring
October 13, 2009
Question

Passing stage/root variables to movie clip

  • October 13, 2009
  • 2 replies
  • 4659 views

First decent foray into AS3....

Just need to figure out how to pass root level variable to a movie clip which contains a dynamic text box to display the passed variable. How is this possible? I usually use global variables when i was coding in AS2...but it appears this feature is dropped in AS3.

This topic has been closed for replies.

2 replies

Inspiring
October 13, 2009

Also you may access a variables from timeline in any time after executing an all construktors in the frame.

If you have a variable in maintime line:

var testVar: String = "TEST_STRING";

you can access this var form any movie in this way:

MovieClip( this.root ).testVar;

but only in methods different from c-tor.

FlashTapper
Inspiring
October 13, 2009

Thanks for that...did a trace of the variable and it appeared from within the movie clip. I still have trouble displaying the number variable in the text box within the movie clip...i am writing it as thus:

MovieClip(this.root).score = scoreText.text;

It's not working.

Inspiring
October 13, 2009

you can do it if the type is a MovieClip.

Lets say, you have some movieClip called "myMovieClip" which is the instance name on stage.

then what you can do is

myMovieClip.myVariable = "my value";

then you can manupulate it as you like.