# AS2: need help: timer that randomly plays sequence in movie

**URL:** <https://forum.kirupa.com/t/as2-need-help-timer-that-randomly-plays-sequence-in-movie/248590>\
**Category:** flash\
**Created:** [January 9, 2008, 11:24pm UTC](https://forum.kirupa.com/t/as2-need-help-timer-that-randomly-plays-sequence-in-movie/248590 "2008-01-09T23:24:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michmons](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@michmons](https://forum.kirupa.com/u/michmons)\
**Post date:** [January 9, 2008, 11:24pm UTC](https://forum.kirupa.com/t/as2-need-help-timer-that-randomly-plays-sequence-in-movie/248590/1 "2008-01-09T23:24:50Z")

</div>

[SIZE=1]I have a game that I need to have a character randomly move into positions after an alloted time. I wrote some code that works perfect for my external movies to come in, but I can’t figure out how I would make this code work for one movieclip playing random sequences. I could really use some help.

Here is what I tried. I don’t fully understand arrays and how to incorporate them into functions.

//here are the different sequences in my movie clip:  
[COLOR=DarkGreen]ranMove = [“STANDARD”,“SLEEP”,“LOOK to SIDE”,“LOOK to SIDE SUPRISE”,“FEET on DESK”,“PAPER TOSS”,“TYPING”];

[/COLOR][/SIZE][SIZE=1]//here is the timer code:

[/SIZE][SIZE=1][COLOR=DarkGreen]displayTime = 15;  
function countDown2() {  
displayTime–;  
if (displayTime == 0) {  
displayTime = 15;  
trace(“Character Move”);  
[/COLOR][/SIZE][SIZE=1]//this is the line that I can’t figure out[/SIZE]  
[SIZE=1][COLOR=DarkGreen] gotoAndPlay(ranMove(Math.floor(Math.random()\*7)+1));  
}  
};  
timer = setInterval(countDown2, 1000);[/COLOR]  
[/SIZE]
