Hi everyone - I’m a newbie on kirupa, and I wonder if any of you talented people out there can help with this more-than-likely simple problem.
I have 3 movieclips on a stage, all being instances of a square (mc_square01, mc_square02, mc_square03).
What I want to do is on every reload to have a random movieclip to be the ‘correct answer’ - and this is the bit I’m struggling with.
The way i’m testing this out is just to change the alpha of a movieclip on the stage.
Here’s my code…
var myArray:Array = [mc_square01, mc_square02, mc_square03];
mc_square01.addEventListener(MouseEvent.MOUSE_OVER, chooseMe);
mc_square02.addEventListener(MouseEvent.MOUSE_OVER, chooseMe);
mc_square03.addEventListener(MouseEvent.MOUSE_OVER, chooseMe);
mc_square01.buttonMode = true;
mc_square02.buttonMode = true;
mc_square03.buttonMode = true;
function chooseMe(event:MouseEvent):void {
for (var i:Number = 0; i < myArray.length; i++){
myArray[Math.floor(Math.random() * 3)];
myArray*.alpha = .2;
}
}
I know it’s something to do with the math.random, but as I’m a newbie, I’ve just about bashed my wall down with my forehead with this.
If anybody could help me, I’d be extremely grateful!