Skip to main content
December 19, 2014
Beantwortet

Linking Mc on stage with class Mc

  • December 19, 2014
  • 1 Antwort
  • 322 Ansichten

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.

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von kglad

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);

}

}

1 Antwort

kglad
Community Expert
kgladCommunity ExpertAntwort
Community Expert
December 19, 2014

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);

}

}

December 20, 2014

Thank you!

kglad
Community Expert
Community Expert
December 20, 2014

you're welcome.