how to: random swf loading
- Started
- Last post
- 5 Responses
- modularsin
Hi everyone, I'm trying to add some script to our site that allows for random swf's to be loaded on the main page.
right now I have a blank movie clip on the index page that says loadMovie ("blank") etc. and it loads my one swf but I want to have about 3 different swf's and have one picked at random to load on the main page.
any help with this would be greatly appreciated!
Mark
- modularsin0
if nobody knows dirrectly how to do this, if you know of any helpful actionscript tutorial pages that would also be a great help.
thanx
- Mick0
What I do is create X number of frames, each one with a load movie that loads a different movie.
One the first frame of your movie put in a gotoAndStop (_Currentframe + Random(X));
- tparsons0
Here ya go one line of actionsript.
loadMovie (("random" add (random (3) + 1)) add ".swf", "_root.blankmovie");
Name your 3 movies (random01.swf - random03.swf
Change the target to the instance of your movie container or load it onto a level so you don't need to use contatiners.
- o0o0
or create an array with your movie names, then choose one of those at random... (check the syntax, I'm doing this from memory)
var swfArray = new Array("onemovie.swf", "otherone.swf", "thirdone.swf");
var rnd = Math.round(Math.random()*(swfArr... -1));
load(swfArray[rnd]);the "-1" is because you have 3 elements in your array, but you can't choose swfArray[3], it doesn't exist, only 0,1, and 2 ...
- modularsin0
thanks alot everyone! I think I got it working now.
Peace-