Flasher Archive
[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]
Subject: | Re: FLASH: Randomization in Flash |
From: | Eric Dunham |
Date: | Sun, 16 Jan 2000 17:41:52 GMT |
I don't know if you want a current MC to be able to randomly call other MCs
to load, or if you're wanting to just randomly load a swf when the page
loads. If it is the latter, then it's very simple with JavaScript (or ASP).
Since JavaScript is probably the way you want to go, try the following:
<code>
<script>
<!--
x = Math.round(Math.random()*10);
SWF = "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \n";
SWF += "WIDTH=\"550\" HEIGHT=\"400\" \n";
SWF +=
"CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0
,0,0\"> \n";
SWF += "<PARAM NAME=\"MOVIE\" VALUE=\"movie" +x+ ".swf\"> \n";
SWF += "<PARAM NAME=\"PLAY\" VALUE=\"false\"> \n";
SWF += "<PARAM NAME=\"LOOP\" VALUE=\"false\"> \n";
SWF += "<PARAM NAME=\"QUALITY\" VALUE=\"best\"> \n";
SWF += "<PARAM NAME=\"BGCOLOR\" VALUE=\"#FFFFFF\"> \n";
SWF += "<EMBED SRC=\"movie" +x+ ".swf\" WIDTH=\"550\" HEIGHT=\"400\" \n";
SWF += "PLAY=\"false\" LOOP=\"false\" QUALITY=\"best\" BGCOLOR=\"#FFFFFF\"
\n";
SWF +=
"PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro
d_Version=ShockwaveFlash\"> \n";
SWF += "</EMBED>\n</OBJECT>";
document.write(SWF);
//-->
</script>
</code>
Now you might be asking why the hell I separated all the lines when
assigning values to the variable SWF. If you don't know why I did
that...well, nevermind why I did that, you can change it if you wish.
Needless to say, this is what you would need to do to randomize the call of
a Flash movie into an HTML page. As I'm sure you've realized
Math.round(Math.random()*10) is what does all the magic. If you don't know
about the JavaScript Math object (and yes, it does have to have a capital
"M") I'll tell you what those two things do. Math.random() generates a
random number between 0 and 1 (and it can go out to an insane number of
decimal places). The result of the random generation is multiplied by 10,
giving us a number X, where 0<=X<10. Now we call the Math.round method,
specifying the random generation we just did as the argument, and there you
have it. The rounding method has now given you an integer between 0 and 10,
inclusive. The example that I just wrote assumes that your movies are named
movie0.swf, movie1.swf, etc. but you may change that however you wish.
Hope that helps,
Eric Dunham
> Anyone know how to randomize a bunch of MCs so that a random one is shown
> when a user visits the page. Would be helpfull if it were done in Flash3.
> Thanks.
flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Streaming Media WEST '99 Conference & Exhibition
"The Worlds largest Internet Audio & Video Event"
December 7 - 9, San Jose Convention Center, California
Reserve your space today at http://www.streamingmedia.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpchinwag [dot] com
Replies
FLASH: Randomization in Flash, David L. Salvaggio
Re: FLASH: Randomization in Flash, Kilroy
[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]