# Randomized timer events

**URL:** <https://forum.kirupa.com/t/randomized-timer-events/276315>\
**Category:** Uncategorized\
**Created:** [November 25, 2008, 6:51pm UTC](https://forum.kirupa.com/t/randomized-timer-events/276315 "2008-11-25T18:51:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![juskin](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@juskin](https://forum.kirupa.com/u/juskin)\
**Post date:** [November 25, 2008, 6:51pm UTC](https://forum.kirupa.com/t/randomized-timer-events/276315/1 "2008-11-25T18:51:50Z")

</div>

So I want to randomize a timer event for a game. I really would like it to select different times in an array, but first i am just trying to randomize it here is the code:

stop();

var clipATimer:Timer = new Timer(Math.random() \* 5000);  
clipATimer.addEventListener(TimerEvent.TIMER, clipAhit);  
function clipAhit (e:TimerEvent):void {  
gotoAndStop(“windowAopen”);  
trace(“timer fired”);  
}  
clipATimer.start();

it seems to work, however after the first time it fires, it just keeps firing.

so this is what I thought would work, but Im sure the syntax is incorrect…  
var timeArray = new Array(“1500” , “2000” , “3000”)

var clipATimer:Timer = new Timer(Math.random(timeArray) \* 5000);  
clipATimer.addEventListener(TimerEvent.TIMER, clipAhit);  
function clipAhit (e:TimerEvent):void {  
gotoAndStop(“windowAopen”);  
trace(“timer fired”);  
}  
clipATimer.start();
