Here we go, I fixed and cleaned it up for you.
Code:
// Generate a Random Number
var movieDis; //global variable
var number = 2; //your number of videos -1
var randomnumber = Math.round(Math.random()*number+1); //generate a random number between 1-number+1
movie(randomnumber);
//Functions to write out the correct flash movie resource.
function movie(num){
if(num == 1){
movieDis = "<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width=\'855\' height=\'500\'><param name=movie value='index.swf'><param name=quality value=high><embed src='index.swf' quality=high pluginspage=\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\' type=\'application/x-shockwave-flash\' width=\'855\' height=\'500\'></embed></object>";
} else if(num == 2){
movieDis = "<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\' width=\'855\' height=\'500\'><param name=movie value='index2.swf'><param name=quality value=high><embed src='index2.swf' quality=high pluginspage=\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\' type=\'application/x-shockwave-flash\' width=\'855\' height=\'500\'></embed></object>";
}else if(num == 3){
movieDis = "<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\' width=\'855\' height=\'500\'><param name=movie value='index3.swf'><param name=quality value=high><embed src='index3.swf' quality=high pluginspage=\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\' type=\'application/x-shockwave-flash\' width=\'855\' height=\'500\'></embed></object>";
} else {
movieDis = "There was an error. Please try again."; //error
}
document.write(movieDis);
}
When you want to add another movie, the highlighted is where you want to add another number. That indicates the number of movies -1, so for now you've got 3 mvoies, so I put it at 2, 3-1=2(if you didn't know.
). To add another movie, simply add:
Code:
}else if(num == x){
movieDis = "null for now. :D";
Before the } else {. The first highlighted is a variable x, thats the number indicating what number movie it is. And the second highlighted "null for now.
" is where your gonna want to put your object.
Also I see that if the randomnumber equals 0 in your script, it will go to movie1(same as in my script). So I think that this is gonna function right and exactly how yours does, except... Well... Without the part that it doesn't work.
Bookmarks