Flash Random Scene ActionScript

Published by 8 Comments

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);
case 1:
gotoAndPlay(“scenename1”, 1);
case 2:
gotoAndPlay(“scenename2″, 1);
trace ( ” no case tested true ” )

That’s it!
Ashton Sanders

(P.S. If this was useful for you, please leave a comment! ;))

Tags: , , , ,

Categorised in: Flash ActionScript

This post was written by Ashton