PDA

View Full Version : Remove gotoAndPlay from MC



ryrocks
April 2nd, 2009, 03:43 PM
Hey,

Is it possible to remove a gotoAndPlay from a movieclip?

for example:

start an animation.
When the animation reaches frame 50, gotoAndPlay(1)
This will make frames 1-50 play on loop.

is it possible to run this loop twice and then let the movie carry on playing past frame 50?

Thanks in advance.

jwerre
April 2nd, 2009, 04:10 PM
you could use an enter frame event to track the current frame like this:



stop();
var count:int;
addEventListener(Event.ENTER_FRAME, _enterframeHandler);

function _enterframeHandler(event:Event):void {
nextFrame();
if(currentFrame >= 50){
count++
if(count > 2){
removeEventListener(Event.ENTER_FRAME, _enterframeHandler);
stop();
}
}

}




Hey,

Is it possible to remove a gotoAndPlay from a movieclip?

for example:

start an animation.
When the animation reaches frame 50, gotoAndPlay(1)
This will make frames 1-50 play on loop.

is it possible to run this loop twice and then let the movie carry on playing past frame 50?

Thanks in advance.

cessnajumpin
April 2nd, 2009, 04:16 PM
A quick "down and dirty" way of doing this would be to add this to frame one:

var loopAmt:Number = 0;

And then on frame 50:


loopAmt++;
if(loopAmt <= 2)
{
gotoAndPlay(2);
}


A quick note: you'll have to start the gotoAndPlay at frame 2 or else the loopAmt would keep resetting to 0 everytime it played through. If it's that big of an issue just have frame 1 and 2 the exact same thing and put the rest of the code on frame 51.

ryrocks
April 2nd, 2009, 09:16 PM
Thanks guys, much appreciated. I'll give the down and dirty option ago, it looks good!