Copy link to clipboard
Copied
Hello
I am trying to tell mc on stage to react to another one that is called by addchild and has a class name. I am doing this from the main timeline. How can I achieve this?
if
(this.currentFrame == 3) //Mc with class name that is on stage with addchild method. Called Mcl1//
Mcl2.gotoAndPlay(1) //Mc physically on stage with instance name//
Do I have to add enterframe events listener on the main timeline. (There is already one inside Mcl1 class code).
Any help is appreciated. Thanks.
if you want to do something when the current timeline reaches frame 3, yes you need to use a loop (like enterframe or a timer loop) to repeatedly check when the current frame is = 3.
eg,
this.addEventListener(Event.ENTER_FRAME,enterframeF);
function enterframeF(e:Event):void{
if(this.currentFrame==3){
Mcl2.gotoAndPlay(1);
this.removeEventListener(Event.ENTER_FRAME,enterframeF);
}
}
Copy link to clipboard
Copied
if you want to do something when the current timeline reaches frame 3, yes you need to use a loop (like enterframe or a timer loop) to repeatedly check when the current frame is = 3.
eg,
this.addEventListener(Event.ENTER_FRAME,enterframeF);
function enterframeF(e:Event):void{
if(this.currentFrame==3){
Mcl2.gotoAndPlay(1);
this.removeEventListener(Event.ENTER_FRAME,enterframeF);
}
}
Copy link to clipboard
Copied
Thank you!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now