-
creating a random number problem.
// Ive created an array with three items.Button named random btn is to give the result of a random number of one, two, three.
// Now the result after the button is pressed is only selecting one random number out of the three. Then the button is repeats the result each time the button is pressed.
as an example say the number one is chosen number one. Press the random btn and thats the only number which is choosen.
var targetArray:Array = new Array("one", "two", "three");
// this makes a random number
var randomNum = random(targetArray.length);
randomBtn.onPress = function(){
trace(randomNum);
}
hansolo is online now Report Post Edit/Delete Message
-
Flash/Flex Developer
Not sure if I understand your question. If you limit the number of choices to the random command, then it limits your results.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
no ive worked out the problem the randomNum needed to inside the handlers of the button press.
var randomNum ="";
var targetArray:Array = new Array("one", "two", "three");
randomBtn.onPress = function(){
trace(randomNum);
randomNum = random(targetArray.length);
}
-
Flash/Flex Developer
Excellent. Remember to mark this thread as resolved.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|