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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Random SWF from an ARRAY

Status
Not open for further replies.

tmstark

Technical User
Nov 11, 2006
5
US
Hello.

I'm new to Flash, so bear with me.

I'm using a holder SWF with a menu and sidebar to load external SWFs within itself. I want to be able to load a random external SWF into my host SWF for variety and file size purposes. However, the method I'm using to call the external SWFs is I've placed an MC called "transition" over a mask. The first frame of the "transition" mc simply says: _root.section = "whatever.swf";

I do it this way because it's easy for me, and because it's a part of the transition animation.

How can I adapt "_root.section = "whatever.swf";" to call on a random SWF from an array?
 
Try this...

Code:
movie_array = ["swf1.swf","swf2.swf","swf3.swf","swf4.swf","swf5.swf"];

_level0.my_random = Math.floor(Math.random()*movie_array.length-1)+1;
_level0.section = movie_array[_level0.my_random];

trace(_level0.section);

Regards. Web Hosting - Web Design
03/13/05 -> OLDNEWBIE VS FLASHKIT
 
It works perfectly. Thanks a lot for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top