PDA

View Full Version : Random Box


mightymo
03-17-2009, 06:29 AM
Hello,
I have a simple question I think. I have 2 boxes on my flash site. I want to be able to place a symbol (like a check mark) in either of the boxes and if the right one is selected it says correct and moves on to the next level. I want the boxes to be random so you will never know which one is the right box. I have read through allot of actionscript code and wasn't sure how to right it. I was thinking of using the math.floor (math.random) code on each box if thats correct but wasnt sure how to light the boxes up so whichever has the higher number is the correct one. Can anyone help me with this?

kkbbcute
03-18-2009, 11:54 AM
Can you post your source code? Thanks:)

I think it should be quite simple to do, since you only have to boxes. Here's the rough idea, generate randomly either 0 or 1. If 0 is generated, then box1._x = pos1, where pos1 is a variable of your first position, and box2._x = pos2, where pos2 is yet another variable. When your random number is 1, just flip the pos1 and pos 2 around using a if/else statement.

kkbbcute
03-22-2009, 01:30 PM
Sorry for the double post, but I just wanted to have a clear distinction here.

Attached is the source file and everything is completed.

Cheers!:)