I want to do something like this with a variable in actionscript 3, you can ignore the randomNumber function. It’s just to make my question more clear about what I’m doing:
function randomNumber(low:Number=0, high:Number=1):Number {
return Math.floor(Math.random() * (1+high-low)) + low;
}
randomNumber(1, 3)
var selection:int = randomNumber;
mymovieclip.insideclip(selection);
So I want to basically use the contents of the variable to choose a certain movieclip. You can imagine there are multiple insideclip’s. So something like insideclip1, insideclip2, insideclip3. I randomly choose a number and put it in a variable called selection, then I want to use mymovieclip.insideclip1, 2 or 3 depending on what number that variable stores.
I’m sure there’s a way to do this someone can direct me to figuring out.
There are many many ways to do this (also based on what you want). One way, you could just store all the “insideclips” in to an array then choose a random index.