# If statement and random movieclip?

**URL:** <https://forum.kirupa.com/t/if-statement-and-random-movieclip/312459>\
**Category:** Uncategorized\
**Created:** [August 3, 2010, 11:33pm UTC](https://forum.kirupa.com/t/if-statement-and-random-movieclip/312459 "2010-08-03T23:33:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![markyT](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@markyT](https://forum.kirupa.com/u/markyT)\
**Post date:** [August 3, 2010, 11:33pm UTC](https://forum.kirupa.com/t/if-statement-and-random-movieclip/312459/1 "2010-08-03T23:33:51Z")

</div>

Hi everyone,

I wonder if anyone can help me. I’m creating a small guessing game where on stage there are 6 squares, and the user has to click on a square, and see if it’s the correct one (it should be a bit more exciting when it’s finished!)  
The random answer is created using the math.random method and I’m using an array for the square movieclips. The problem I now have is with the IF/ELSE statements. Normally this wouldn’t be a problem for me, but seen as I’m calling a random movieclip, I’m stumped.

Please have a look at the following code, and the bit I need you boffins to look at is just after the if statement.

var myArray:Array = [mc\_square01, mc\_square02, mc\_square03, mc\_square04, mc\_square05, mc\_square06];

myArray[Math.floor(Math.random() \* myArray.length)].addEventListener(MouseEvent.MOUSE\_DOWN , chooseMe);

function chooseMe(event:MouseEvent):void {

```
	if (WHAT GOES HERE??????){
    reply_txt.text = "Good Job!";
	event.target.alpha = .2;
	 
    } else {
    reply_txt.text = "Try Again!";
	
    }

```

}

Any help, as ever, is gratefully received. And thanks again to ‘thehat’ earlier for his actionscript wisdom.
