/    Sign up×
Community /Pin to ProfileBookmark

Choosing a random SWF using javascript

I have a very simple snippet of javascript on my website that loads has an array of SWF’s and a rand method which chooses one at random and plays it and it works fine, unless I have more than 10 videos, at which point random videos stop playing, even videos that are between 0-9.

Below is the <script>, can someone please guide me as to how I can make something like this work?

[CODE] <script language=”javascript” src=”http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/js/swfobject.js”></script>
<script language=”javascript”>
var params = {
loop: “false”
};
var swfs = new Array();
swfs[0] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_hula_drum.swf”;
swfs[1] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_hula_symphony.swf”;
swfs[2] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_flight.swf”;
swfs[3] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_haleakala.swf”;
swfs[4] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_genesis.swf”;
swfs[5] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_firebird.swf”;
swfs[6] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_wave.swf”;
swfs[7] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_marine.swf”;
swfs[8] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_rainforest.swf”;
swfs[9] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_whale.swf”;
swfs[10] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_lava.swf”;
swfs[11] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_waena.swf”;
swfs[12] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_sun.swf”;
swfs[13] = “http://hnuzf.spdqg.servertrust.com/v/vspfiles/templates/Titanium_Tes/flash/intro_waterfall.swf”;
function getRandomSWF() {
var rnd = Math.floor(Math.random() * swfs.length);
return swfs[rnd];
};
swfobject.embedSWF(getRandomSWF(), “flashcontent”, “1024”, “576”, “10,0,0,0”, “loop=false”);
document.write(getRandomSWF());
</script>[/CODE]

The web site is [url]http://hnuzf.spdqg.servertrust.com/default.htm[/url]

Thank you
Ken

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @advolente 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...