# Random animations

**URL:** https://forum.kirupa.com/t/random-animations/259014
**Category:** flash
**Created:** [April 30, 2008, 11:09am UTC](https://forum.kirupa.com/t/random-animations/259014 "2008-04-30T11:09:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![prakibo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@prakibo](https://forum.kirupa.com/u/prakibo)
#### Post date: [April 30, 2008, 11:09am UTC](https://forum.kirupa.com/t/random-animations/259014/1 "2008-04-30T11:09:51Z")

</div>

I have 16 different animations in 16 different Movieclips in the Library.

I want them to play in a random order 1 after another from the library and exactly after all 16 play the loop should stop automatically.

I used array and have written the following “for” loop to play this.

* * *

var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];  
var selectedNumbers = [];  
var j = 1;  
var i = 0;

for (var i = 1; i\<16; i++) {  
myvar = handle.createEmptyMovieClip(“mc”+i, i);  
handle[“mc”+i].attachMovie(“movieclip”+i,“movieclip17”+i,i);  
var index = random(numbers.length);  
\_root[“movieclip”+i].count.text = numbers[index];  
trace(numbers[index]);  
selectedNumbers.push(numbers[index]);  
numbers.splice(index,1);  
}

* * *

but when i play, all the 16 animations runs together without any interval.  
Please can someone modify this script and suggest how to play only 1 animation at a time?  
I am not sure how to place the “setInterval” function which i think will delay the loop each time.

Thanks in advance…
