I've got an animation (arrows following paths on a map), and I need it to repeat about 10 times per second, so that there's an endless stream of arrows following their paths.
How can I repeat the m开发者_高级运维ovie clip to achieve this?
If your MovieClip is a single arrow following a path, you will need to instantiate several MovieClips at regular intervals in order to create a continuous stream of arrows.
private var timer:Timer = new Timer( 100 );
private function init():void
{
timer.addEventListener( TimerEvent.TIMER , createArrow );
timer.start();
}
private function createArrow( event:TimerEvent ):void
{
var arrowMc:MovieClip = new ArrowMc();
//here you should add a Complete Event listener
//so that when the MovieClip is complete
//you can remove it from the stage...
//for this to work your arrowMc should dispatch a Complete
//Event on the last frame!
addChild( arrowMc );
}
Alternatively, depending on your animations, you can simply instantiate a fixed number of animations MC and let them loop. Same as above, if your animation is a single arrow moving along a path, instantiate a fixed number by setting a limit to the Timer
private var timer:Timer = new Timer( 100 , 10);
//etc...
Use a Timer to call the function that animates your arrows at a fixed interval, or if you want only one arrow at a time, dispatch an Event when the animation finishes, and add a listener that will call your function when the event is dispatched.
This is a very old question but here is my answer to this. The MC is a basic animation using a guide layer. I am placing the MC on the stage multiple time and then using an interval to repeat the MC in 1 second intervals. "redBox" is the class name used when you export the MC to actionscript.
var redBtn:redBox;
function attachRedBoxes () {
for (var i:Number = 0; i < 5; i++) {
redBtn = new redBox ();
redBtn.ID = i;
redBtn.name = "button_" + i;
addChild (redBtn);
}
}
setInterval(attachRedBoxes,1000);
精彩评论