Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stopping on the last frame (flash)

I want my movieclip to play once and stop on the last frame. I use the following code in the loop of my movieclip class. (this is as3)

if(currentFrame == 120)
stop();

120 is the last frame. It plays once. but the problem is it goes back to frame 1 again. is there a better method of stopping a movieclip on a particular frame.

like image 522
numerical25 Avatar asked Jan 20 '10 04:01

numerical25


1 Answers

If you want to do it with actionscript and not add a stop() to the last frame on the timeline manually, then you can use the undocumented addFrameScript() method.

mc.addFrameScript(mc.totalFrames - 1, function():void 
{
    mc.stop();
});

Can't remember the scope of the function, but you can either use mc.stop(), or just stop().

*EDIT - Added -1 to the first parameter of addFrameScript, because it is zero based (so to put a frameScript on frame 10 you would put 9).

like image 64
Adam Harte Avatar answered Oct 12 '22 22:10

Adam Harte