# Random function selection

**URL:** <https://forum.kirupa.com/t/random-function-selection/234949>\
**Category:** Uncategorized\
**Created:** [August 7, 2007, 12:54pm UTC](https://forum.kirupa.com/t/random-function-selection/234949 "2007-08-07T12:54:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [August 7, 2007, 12:54pm UTC](https://forum.kirupa.com/t/random-function-selection/234949/1 "2007-08-07T12:54:00Z")

</div>

hello,

I am trying to get a random MC to play every 15 seconds. Using setInterval.

Here is my code \>  
What seems to be incorrect is that the setInterval doesnt seem to be collecting the function which starts the MC.

function car1(){  
car\_mc.\_x = 1130;  
car\_mc.tween("\_x",-300,4,“easeinSine”);  
}  
function car2(){  
car\_mc.\_x = 1130;  
car\_mc.tween("\_x",-400,4,“easeoutSine”);  
}  
function automob(){  
var ran:Number = Math.ceil(Math.random()\*2);  
carran;  
trace (ran);  
trace (car[ran]);  
}  
setInterval(automob,15000);
