# Timer HELP

**URL:** https://forum.kirupa.com/t/timer-help/194288
**Category:** flash
**Created:** [July 21, 2006, 9:28pm UTC](https://forum.kirupa.com/t/timer-help/194288 "2006-07-21T21:28:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pyroki](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@pyroki](https://forum.kirupa.com/u/pyroki)
#### Post date: [July 21, 2006, 9:28pm UTC](https://forum.kirupa.com/t/timer-help/194288/1 "2006-07-21T21:28:49Z")

</div>

like i said bfore i am making a totally scripted random animation thing and need some help. I am trying to use a timer so that every 4 seconds it will attach movieclips, but dont know how to script it. cud som1 help me. this is what i got so far.

```auto
 
onEnterFrame = function() {
 //random number generator
 rand = Math.random()*20;
 //how many movie clips should be on the screen at once
 obstacles = 2;
 curobs = 0;
 time = Math.floor(getTimer()/1000);
 if(time == 4) {
  //if rand is greater than or equal to 16 load rail
  if(rand >= 16) {
   _root.attachMovie("rail", "rail" + rand, rand)
  }
  //if rand is between 5 and ten load gap
  if( (rand > 5) and (rand < 7)) {
   _root.attachMovie("gap", "gap" + rand, rand)
  }
  //if rand is less than or equal to 5 load wall
  if(rand <= 5) {
   _root.attachMovie("wall", "wall" + rand, rand)
  }
 }
}

```
