Question
creating sequential move clips
hello,
I have a two-part question. How to delay and make the creation of movie clips sequential? Also, how to add a play button?
I am trying to create a group of movie clips and animate them. However, I don't want to have them animate all at once. I need to create one, have it animate, then create another, etc.
When I run the code below the for-loop runs very fast. The clips are all created at once. After five seconds, I get a lot of trace statements from the timer's listener function. The timer doesn't slow down the for-loop.
I'm also trying to find a solution that enables stop and start buttons. I didn't include anything for the stop button, because that's pretty easy. However, i haven't managed to put any code for a play button that works.
To visualize my project, I have a loop creating movie clips. I want subsequent movie clips to wait for the prior movie clip to finish animating before it gets animated. I also want to stop and start this action with stop-start buttons.
Here's my code. I hope this post isn't like asking for the Moon. :))
btnPlay.addEventListener(MouseEvent.CLICK, playsShow);
var isPlaying:Boolean = true;
function playsShow(e:Event):void {
if (!!sPlaying)
{
play();
isPlaying = true;
}
}
function runMany(event:Event):void {
trace('runMany called @ ' + getTimer() + ' ms');
}
function mcAdded(event:Event):void {
trace("mcAdded() called @ " + getTimer() + " ms");
var myTimer:Timer = new Timer(5000, 1);
myTimer.addEventListener(TimerEvent.TIMER, runMany);
myTimer.start();
removeEventListener(Event.ADDED_TO_STAGE, mcAdded);
}
// create move clips
for (var j:int=0; j< 250; j++)
{
var FromLibrary:Class=getDefinitionByName("mcDynamicText") as Class;
var mctxt:MovieClip=new FromLibrary();
mctxt.addEventListener(Event.ADDED_TO_STAGE, mcAdded);
addChild(mctxt);
}
I have a two-part question. How to delay and make the creation of movie clips sequential? Also, how to add a play button?
I am trying to create a group of movie clips and animate them. However, I don't want to have them animate all at once. I need to create one, have it animate, then create another, etc.
When I run the code below the for-loop runs very fast. The clips are all created at once. After five seconds, I get a lot of trace statements from the timer's listener function. The timer doesn't slow down the for-loop.
I'm also trying to find a solution that enables stop and start buttons. I didn't include anything for the stop button, because that's pretty easy. However, i haven't managed to put any code for a play button that works.
To visualize my project, I have a loop creating movie clips. I want subsequent movie clips to wait for the prior movie clip to finish animating before it gets animated. I also want to stop and start this action with stop-start buttons.
Here's my code. I hope this post isn't like asking for the Moon. :))
btnPlay.addEventListener(MouseEvent.CLICK, playsShow);
var isPlaying:Boolean = true;
function playsShow(e:Event):void {
if (!!sPlaying)
{
play();
isPlaying = true;
}
}
function runMany(event:Event):void {
trace('runMany called @ ' + getTimer() + ' ms');
}
function mcAdded(event:Event):void {
trace("mcAdded() called @ " + getTimer() + " ms");
var myTimer:Timer = new Timer(5000, 1);
myTimer.addEventListener(TimerEvent.TIMER, runMany);
myTimer.start();
removeEventListener(Event.ADDED_TO_STAGE, mcAdded);
}
// create move clips
for (var j:int=0; j< 250; j++)
{
var FromLibrary:Class=getDefinitionByName("mcDynamicText") as Class;
var mctxt:MovieClip=new FromLibrary();
mctxt.addEventListener(Event.ADDED_TO_STAGE, mcAdded);
addChild(mctxt);
}