Sunday, March 9, 2008

Flash Random Scene ActionScript

Websites in a Flash Mascot I recently created a Flash Animation that would randomly play one of three different Flash scenes. Then after each scene, it would go back to the beginning and randomly choose another scene to play. This was all programmed in ActionScript in Flash.

I have a feeling that even though this code is very simple, it will save a little bit of time if I have it stored here for the future.

// First Choose a random number
//from 0 to the number of scenes
num = random(3);

//Depending on which random number
//was chosen, go to a flash scene
switch (num)
{
  case 0:
    gotoAndPlay("scenename", 1);
    break;
  case 1:
    gotoAndPlay("scenename1", 1);
    break;
  case 2:
    gotoAndPlay("scenename2", 1);
    break;
  default:
    trace ( " no case tested true " )
}
That's it!
-Ashton Sanders

Labels: , ,

2 Comments:

Blogger dizitalART said...

hi ashton, looks good i was looking some like this. where do we put this script? in the first scene?

March 13, 2008 5:58 PM  
Blogger Ashton Sanders said...

Hi,

Yes. Make the first scene a blank screen, and put this code in one of the frames.

Then have the end of each of your scenes redirect back to the beginning of the first scene.

March 14, 2008 2:14 PM  

Post a Comment

<< Home