i want to add two movieclips. one is shaking bar, i want to add the second movieclip after 5 seconds after the first one, i tried bu didn’t work as i want. when the second finishes, i want all the movievlips stop and then start again. how can i loop like this.
import flash.events.Event;
// first movieclip,. this bar is shaking
var bargrey:greybar = new greybar();
bargrey.x=100;
bargrey.y=75;
addChild(bargrey);
bargrey.addEventListener(Event.ENTER_FRAME, shakeIt);
var posx:Number = bargrey.x;
var posy:Number = bargrey.y;
function shakeIt(event:Event):void {
bargrey.x = posx+(Math.floor(Math.random()*1));
bargrey.y = posy+(Math.floor(Math.random()*3));
bargrey.rotation = Math.random()*1;
}
/This is the time delay function that i use. it waits 5 seconds than adds the second movieclip but ENTER_FRAME loads the clip again and again. i dont know if this is the right way/
var startTime=getTimer();
stage.addEventListener(Event.ENTER_FRAME, timeDelay);
function timeDelay(event:Event):void {
var timePassed=getTimer();
if (timePassed-startTime >= 5000) {
var up_bars:Up_mc = new Up_mc();
addChild (up_bars);
//when it finishes the animation i want all the clips stop and than start. loop like this
}
}