25 August 2008

Random Welcome Screen

I love tricky way to generate random frame to be stopped. For example, you have frame 1-10 with different movie clip on it. So,whenever user click a button,they will get surprises with different welcome screen.

Here we go.

on (release) {

// Sets the number of digits in the random sequence:
var mySetting = 3;

// Creates a random number:
myNumber = random(mySetting)+1;

// Checks to see if it is repeating itself:
if (myNumber == myTemp) {
// If it is repeating it generates a new random number:
myNumber = random(mySetting)+1;
gotoAndStop(myNumber);
// Continues as above:
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
gotoAndStop(myNumber);
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
gotoAndStop(myNumber);
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
gotoAndStop(myNumber);
}
}
}
}
// Displays the random number:
myDisplay = myNumber;
// Resets the variable to the new random number:
myTemp = myNumber;
}

Thanks for Phil Sculz for sharing this.

PPL IAIN Syekh Nurjati Cirebon

Jika ditanya apa yang kau suka dari kehadiran mereka? Mereka punya jawabannya : semangat yang tinggi dengan keingintahuan yang tipikal mahas...