0

Hey guys, just trying things out trying to get practice with this thing. Right now I'm trying to get a simple animation to loop over and over after one button press. I decided to try to achieve this I'm trying to use a while loop. But so far I'm having no luck. Once the button is pressed it just plays the movie once. Heres the code I know i'm doing something wrong. I just don't know what, It's most likely something with the scope of the loop. I Just wouldn't know where else to put the loop.

function clickThis(eventType:MouseEvent):void
{
	var p:Number =0;
	
	while (p < 10)
	{
	gotoAndPlay(1);
	p++; 
	}
}

play1.addEventListener(MouseEvent.CLICK,clickThis);

Thanks guys,
-Soapy

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Varnius
0

Loop will not help you to loop over your animation. because its working based on your fps which is set wihin your fla. So what you can do is

i) Assume that you have 100 frames
ii) at the end of the 100th frame add an action as gotoAndPlay(1) in timeline. It will loop over your animation forever.

0

Putting gotoAndPlay() to a frame won`t be such a good idea if there are a lot of buttons. I`d solve this by adding onEnterFrame event handler and looping it until certain condition is met.

Edited by Varnius: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.