Copy link to clipboard
Copied
Hello, I wonder how I can randomly select a condition, the following code has been made, but only the condition 2 is used, as can for to be randomly selected one of theconditions?
Grateful!
var luck:Number = 3;
if (luck == 1) {
gotoAndPlay(1);
return 0;
}
if(luck == 2) {
addChild(movie);
}
if(luck == 3) {
gotoAndPlay(1);
return 0;
}
var luck:uint = Math.abs(Math.random() * 3);
But this returns a random number between 0,1,2 so you have to change it to:
if (luck == 0){
if (luck == 1){
if (luck == 2){
Copy link to clipboard
Copied
var luck:uint = Math.abs(Math.random() * 3);
But this returns a random number between 0,1,2 so you have to change it to:
if (luck == 0){
if (luck == 1){
if (luck == 2){
Find more inspiration, events, and resources on the new Adobe Community
Explore Now