Forum Moderators: open
I know there's a code to rotate images but i can't find a script to rotate swf files.
Please DO NOT post a flash code or anything to use on the flash or swish software. I'm looking for a script to put on my HTML files.
<script language="JavaScript">
// Generate a Random Number
var randomnumber = Math.round(Math.random()*3);
// Select a movie and execute the corresponding function
if (randomnumber == 1)
{movie1();}
else if (randomnumber == 2)
{movie2();}
else {movie3();}
//Functions to write out the correct flash movie resource.
function movie1(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"770\" height=\"150\"><param name=movie value=\"../flash/banner1.swf\"><param name=loop value=false><param name=quality value=high><embed src=\"movie1.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"200\"></embed></object>")
}
function movie2(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"770\" height=\"150\"><param name=movie value=\"../flash/banner2.swf\"><param name=loop value=false><param name=quality value=high><embed src=\"movie2.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"200\"></embed></object>")
}
function movie3(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"770\" height=\"150\"><param name=movie value=\"../flash/banner3.swf\"><param name=loop value=false><param name=quality value=high><embed src=\"movie3.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"200\"></embed></object>")
}
</script>
Hope this helps. You have to modify the number of swf files you are going to rotate as well as the path to the files to match your paths.
<?
$r=rand(1,3);
?>
<object type="application/x-shockwave-flash" data="movie<?=$r?>.swf" width="300" height="40">
<param name="movie" value="movie<?=$r?>.swf" />
</object>
You can apply the same simple principles in the last post to the javascript solution. Just write out the code once and change the src. That will work.
The one bad thing with both of these - especially if you only have three or four files - is that in all cases random can "randomly" pick the same image 3, 5, even 10 times in a row.
You need to store whatever the last image/flash was somewhere so it re-picks if that one is picked, or temporarily remove the "last flash" from your array.