PDA

View Full Version : Random Flash


dreamlynx
12-30-2005, 01:30 AM
Does anyonje know how to make different flash files come up randomly when the page loads.

Creative Insanity
12-30-2005, 01:51 AM
would that not be the same as banner switching?
There are many scripts for banner switching and just replace the image name for your swf file name.
Should work, but I have not tested.

dreamlynx
12-30-2005, 02:51 AM
no banner switching dosen't allow random

Creative Insanity
12-30-2005, 04:42 AM
There are many that do. If I get some time I'll use a search engine for you.

ramandeep
12-30-2005, 09:26 AM
This will do!


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

</body>
<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=\"300\" height=\"200\"><param name=movie value=\"xxxxxxxxxxxxxxxxx"><param name=quality value=high><embed src=\"xxxxxxxxxxxxxxxxx" 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=\"300\" height=\"200\"><param name=movie value=\"xxxxxxxxxxxxxxxxx"><param name=quality value=high><embed src=\"xxxxxxxxxxxxxxxxx" 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=\"300\" height=\"200\"><param name=movie value=\"xxxxxxxxxxxxxxxxx"><param name=quality value=high><embed src=\"xxxxxxxxxxxxxxxxx" 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>

</html>

davidj
01-03-2006, 09:25 AM
ramandeep those function are not good practice

i would just have the one <object> tag in the page as normal and then have the path declaration to each SWF as a variable