1 Reply Latest reply on May 18, 2006 4:24 PM by blemmo

# Calling a random MC

Hi,
I have five MC's that I made and would like to call one of them up with a button action. When one pops up I would like it to choose from one of the five randomly. So, when you click the button, a mc animation will play. If you click another button, it calls another (or the same, since it is random) mc animation and makes it play.

How do I do this?

Thanks.
Van
• ###### 1. Re: Calling a random MC
There are various ways to do that. All of them involve Math.random(), check it out in the Help. This returns a random number between 0 and 1. Because you want a random number between, let's say 1 and 5, you have to do some calculation with the result, like
randNum = Math.round(Math.random()*4+1)
to get a number in that range. There's a better example in the Help how to get numbers in a certain range.
Now this number can be used for loading the clips. Simplest way would be naming the MCs "mc1", "mc2" and so on, and use