Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Question about ENTER_FRAME event listener.

Explorer ,
May 25, 2013 May 25, 2013

Hello. I am using Flash cs6.

Right now I am using this script below.

this.addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void

{

          trace(currentFrame);

          if(currentFrame == totalFrames)

          this..removeEventListener(Event.ENTER_FRAME, onEnterFrame)

}

btn.addEventListener (MouseEvent.CLICK,PLAY);

function  PLAY(event:MouseEvent):void{

          play();

}

And I put stop(); on all frames, so If I click "btn", it starts clip and stop(); stops it.

And I use ENTER_FRAME event listener, but when movie stops I want to stop trace(currentFrame) part.

How to stop "trace" when movie clip stops? I really want to do is I want to use ENTER_FRAME event listener but if I stop movie clip, I want to stop ENTER_FRAME function too.

TOPICS
ActionScript
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2013 May 25, 2013

putting a stop() on each frame makes no sense and there's no reason for an enterframe event. 

you can remove all those stops except for a stop() on the first frame and use:

stop();

btn.addEventListener(MouseEvent.CLICK,PLAY);

function PLAY(e:MouseEvent):void{
nextFrame();

stage.invalidate();

addEventListener(Event.RENDER,renderF);

}

function renderF(e:Event):void{

// check if currrentFrame==totalFrames if that's some use to you

trace(currentFrame);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 27, 2013 May 27, 2013

Thank you for your adivice.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2013 May 27, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines