I have a MovieClip object called coinblock1.
Problem:
Coinblock1 has 6 frames and I want to choose a random frame number from this MC object.
I want to use this number to later update some other variables by using an IF
statement.
Variables to update include the changing of amount of coins earned by the player.
My frame numbers are arranged like this:
frame 1 = 0 coins
frame 2 = 1 coins
frame 3 = 5 coins
frame 4 = 10 coins
frame 5 = 50 coins
frame 6 = 100 coins
How to randomize the range for following frames in the coin block?
I have used the if...else
statement and gotoAndStop
in a currentFrame
.
My Code:
if(coinblock1.hitTestObject(blowfishPong) == true)
{
if (ballSpeedXCoinGame > 0)
{
ballSpeedXCoinGame *= -1;
ballSpeedYCoinGame = calculateBallAngleCoinGame(character.y, blowfishPong.y);
var random1: uint = 0;
random1 = Math.random() * coinblock1.totalFrames;
if (random == 1){
coinblock1.gotoAndStop(1);
Bump.play();
}
else{
if(random == 2){
Coins += 1;
coinblock1.gotoAndStop(2);
}
if(random == 3){
Coins += 5;
coinblock1.gotoAndStop(3);
}
if(random == 4){
Coins += 10;
coinblock1.gotoAndStop(4);
}
if(random == 5){
Coins += 50;
coinblock1.gotoAndStop(5);
}
if(random == 6){
Coins += 100;
coinblock1.gotoAndStop(6);
}
updateTextFieldsCoinGame();
CoinSFX.play();
}
}
}