Cannot access frame in as3 flash

I just switched to AS3. I have a problem accessing timeline variables from MovieClips. In AS2 we used _root.myvar, I checked the links, I found _root is root now in AS3.

I have an isValid variable on the root timeline, and my code inside the movie clip needs the value of this variable for some checks. I have done this:

MovieClip Frame 1:

 if(root.isValid == true) { this.gotoAndStop(4); } 

He returned some undefined property error.

please, help

Thank you

+4
source share
1 answer

You need to specify the root in MovieClip:

 if(MovieClip(root).isValid == true) { this.gotoAndStop(4); } 

he should work then.

+1
source

All Articles