Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

play random movieClips???

Status
Not open for further replies.

HuggerFanta

Technical User
Apr 22, 2002
87
0
0
SE
Hello!
I´m rather new to Flash, but i really like it!

I´m workig with Flash MX and need some help.

I have 10 movieClips that I would like to play randomly!

Can any one help me?

--------------------------------------
Kind regards;
HuggerFanta
 
Hello...

Here is a little something you can use to do that. You will just have to adapt it to whatever system you are using.


// SETUP ARRAY TO HOLD MOVIE NAMES
var movieNames = new Array();
movieNames[0] = "movieOne_mc";
movieNames[1] = "movieTwo_mc";
movieNames[2] = "movieThree_mc";
movieNames[3] = "movieFour_mc";
movieNames[4] = "movieFive_mc";

// GENERATE RANDOM NUMBER BETWEEN 0 AND 4
randomNumber = Math.floor(Math.random()*(5-0))+0

// PLAY MOVIE FUNCTION BASED ON RANDOM NUMBER
playMovie = function(index){
_root[movieNames[index]].play();
}

// CALL PLAY MOVIE FUNCTION AND PASS RANDOM NUMBER
playMovie(randomNumber);


So anyways, hope that helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top