Groups | Blog | Home
all groups > flash actionscript > march 2007 >

flash actionscript : selecting random .swf files


melissa_v
3/19/2007 7:44:48 PM
My code loads random movie clips from the same folder of the files "17_1.swf",
"17_2.swf" and so on to "17_50.swf". If I have files that don't start with
"17_" but I would like to load them anyway without having to change all of
these file names, is there a better way for me to write this code?

In other words, how can I simply have it load all of the movie clips in its
folder rather than just the ones named appropriately?

Thanks :grin;

BTNnext_btn.onRelease=function(){
MCempty_mc.loadMovie("17_"+ (Math.floor(Math.random() * 50) + 1) + ".swf",
"_root.movieclip");
melissa_v
3/19/2007 7:46:39 PM
I forgot also to ask how I can "go back" as in, load the same random movie clip
I just saw if I've already clicked away from it? I have a series of clips and
the user scrolls through them, but if he wants to view the previous one shown,
how can I do that?
eric76
3/19/2007 8:14:27 PM
The first problem u describe I suspect is alot more tricky than when u know the
file name structure. I'm guessing u will have to store all the swf file names
in a file that ur flash can access, or if possible let the web server return a
directory content list which u could parse for *.swf files. Just see to it that
u dont load the swf that u are loading from, which could in worst case lead to
a loop.

For ur second problem, you will need to keep track of the last loaded movie
with a variable, like lastLoaded (which u update just before loading a new swf
with lastLoaded = currentlyLoaded), or keep them in an array (if u want the
possibility of multiple back clicks).
AddThis Social Bookmark Button