/    Sign up×
Community /Pin to ProfileBookmark

HELP NEEDED with RANDOM .SWF SCRIPT

Can somebody help me? I’m a noob, so talk down to me. I need help with a random .swf script. The script I have works fine but I want to modify it so that the same .swf banner will not load twice in a row. As it is now, being completely random, I often get the same banner five or six times in a row. Here is my script as it is now:

<script language=”JavaScript”>

// Generate a Random Number
var randomnumber = Math.round(Math.random()*5);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else if (randomnumber == 2)

{movie2();}

else if (randomnumber == 3)

{movie3();}

else if (randomnumber == 4)

{movie4();}

else {movie5();}

//Functions to write out the correct flash movie resource.

function movie1(){
document.write(“<object classid=”clsid?27CDB6E-AE6D-11cf-96B8-444553540000”

codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0

width=”778″ height=”146″><param name=movie value=”movie1.swf”><param name=quality

value=high><embed src=”movie1.swf” quality=high

pluginspage=”http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFl

ash” type=”application/x-shockwave-flash” width=”778″ height=”146″></embed></object>”)
}

function movie2(){
document.write(“<object classid=”clsid?27CDB6E-AE6D-11cf-96B8-444553540000”

codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0

width=”778″ height=”146″><param name=movie value=”movie2.swf”><param name=quality

value=high><embed src=”movie2.swf” quality=high

pluginspage=”http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFl

ash” type=”application/x-shockwave-flash” width=”778″ height=”146″></embed></object>”)
}

function movie3(){
document.write(“<object classid=”clsid?27CDB6E-AE6D-11cf-96B8-444553540000”

codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0

width=”778″ height=”146″><param name=movie value=”movie3.swf”><param name=quality

value=high><embed src=”movie3.swf” quality=high

pluginspage=”http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFl

ash” type=”application/x-shockwave-flash” width=”778″ height=”146″></embed></object>”)
}

function movie4(){
document.write(“<object classid=”clsid?27CDB6E-AE6D-11cf-96B8-444553540000”

codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0

width=”778″ height=”146″><param name=movie value=”movie4.swf”><param name=quality

value=high><embed src=”movie4.swf” quality=high

pluginspage=”http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFl

ash” type=”application/x-shockwave-flash” width=”778″ height=”146″></embed></object>”)
}

function movie5(){
document.write(“<object classid=”clsid?27CDB6E-AE6D-11cf-96B8-444553540000”

codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0

width=”778″ height=”146″><param name=movie value=”movie5.swf”><param name=quality

value=high><embed src=”movie5.swf” quality=high

pluginspage=”http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFl

ash” type=”application/x-shockwave-flash” width=”778″ height=”146″></embed></object>”)
}

</script>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ayse_incebulutNov 11.2006 — [code=php]

<script type="text/javascript">
<!--

var swf1="dans.swf"
var swf2="bulmaca.swf"
var swf3="inek.swf"
var swf4="yapboz.swf"
var swf5="araba.swf"
var swf6="inekler.swf"
var swf7="canavar.swf"
var swf8="balon.swf"
var swf9="tetris.swf"
var swf10="futbol.swf"
var x=Math.round(Math.random()*9)
if (x==0) x=swf1
else if (x==1) x=swf2
else if (x==2) x=swf3
else if (x==3) x=swf4
else if (x==4) x=swf5
else if (x==5) x=swf6
else if (x==6) x=swf7
else if (x==7) x=swf8
else if (x==8) x=swf9
else x=swf10

document.write('<embed src='+'"'+x+'"'+' width="400px"; height="300" >')

//-->
</script>[/code]
×

Success!

Help @tmstark spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...