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

Recommended Answers

All 2 Replies

Member Avatar for rajarajan2017

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.