# How to start two movieclip than stop and loop like this

**URL:** <https://forum.kirupa.com/t/how-to-start-two-movieclip-than-stop-and-loop-like-this/330172>\
**Category:** flash\
**Created:** [December 10, 2012, 12:08pm UTC](https://forum.kirupa.com/t/how-to-start-two-movieclip-than-stop-and-loop-like-this/330172 "2012-12-10T12:08:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![barlas](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@barlas](https://forum.kirupa.com/u/barlas)\
**Post date:** [December 10, 2012, 12:08pm UTC](https://forum.kirupa.com/t/how-to-start-two-movieclip-than-stop-and-loop-like-this/330172/1 "2012-12-10T12:08:05Z")

</div>

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  
}  
}
