Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
Thank you for your adivice.
Copy link to clipboard
Copied
you're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more