VisionsIC
05-16-2005, 11:45 PM
Hi All,
Maybe someone can point out what I have done wrong here? I'm trying to get JavaScript & HTML to rotate my .swf files at random. I successfully had it working with image files, but can't seem to get it to function with my .swf files?
Here is the page in question:
http://www.visionsic.com/sm_randomimage.htm
And here is the suspect Javascript & HTML code:
HEAD Tag Code
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var interval = 20.0; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var object_index = 0;
object_list = new Array();
object_list[object_index++] = new objectItem("/services/pics/r_pic01.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic02.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic03.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic04.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic05.swf");
object_list[object_index++] = new ObjectItem("/services/pics/r_pic06.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic07.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic08.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic09.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic10.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic11.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic12.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic13.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic14.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic15.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic16.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic17.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic18.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic19.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic20.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic21.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic22.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic23.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic24.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic25.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic26.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic27.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic28.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic29.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic30.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic31.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic32.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic33.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic34.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic35.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic36.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic37.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic38.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic39.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic40.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic41.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic42.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic43.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic44.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic45.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic46.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic47.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic48.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic49.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic50.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic51.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic52.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic53.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic54.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic55.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic56.swf");
var number_of_object = object_list.length;
function objectItem(object_location) {
this.object_item = new Object();
this.object_item.src = object_location;
}
function get_ObjectItemLocation(objectObj) {
return(objectObj.object_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextObject() {
if (random_display) {
object_index = generate(0, number_of_object-1);
}
else {
object_index = (object_index+1) % number_of_object;
}
var new_object = get_ObjectItemLocation(object_list[object_index]);
return(new_object);
}
function rotateObject(place) {
var new_image = getNextObject();
document[place].src = new_object;
var recur_call = "rotateObject('"+place+"')";
setTimeout(recur_call, interval);
}
// End -->
</script>
BODY Tag Code
<body OnLoad="rotateObject('rObject')">
<div align="right">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="rObject" width="165" height="135" id="rObject">
<param name="movie" value="services/pics/r_pic01.swf">
<param name="quality" value="high">
<embed src="services/pics/r_pic01.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="165" height="135"></embed>
</object>
</div>
</body>
If anyone knows my mistake, and can help, it'd greatly be appreciated!
Thanks,
Aaron
Maybe someone can point out what I have done wrong here? I'm trying to get JavaScript & HTML to rotate my .swf files at random. I successfully had it working with image files, but can't seem to get it to function with my .swf files?
Here is the page in question:
http://www.visionsic.com/sm_randomimage.htm
And here is the suspect Javascript & HTML code:
HEAD Tag Code
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var interval = 20.0; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var object_index = 0;
object_list = new Array();
object_list[object_index++] = new objectItem("/services/pics/r_pic01.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic02.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic03.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic04.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic05.swf");
object_list[object_index++] = new ObjectItem("/services/pics/r_pic06.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic07.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic08.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic09.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic10.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic11.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic12.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic13.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic14.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic15.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic16.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic17.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic18.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic19.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic20.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic21.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic22.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic23.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic24.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic25.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic26.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic27.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic28.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic29.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic30.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic31.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic32.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic33.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic34.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic35.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic36.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic37.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic38.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic39.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic40.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic41.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic42.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic43.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic44.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic45.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic46.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic47.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic48.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic49.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic50.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic51.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic52.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic53.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic54.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic55.swf");
object_list[object_index++] = new objectItem("/services/pics/r_pic56.swf");
var number_of_object = object_list.length;
function objectItem(object_location) {
this.object_item = new Object();
this.object_item.src = object_location;
}
function get_ObjectItemLocation(objectObj) {
return(objectObj.object_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextObject() {
if (random_display) {
object_index = generate(0, number_of_object-1);
}
else {
object_index = (object_index+1) % number_of_object;
}
var new_object = get_ObjectItemLocation(object_list[object_index]);
return(new_object);
}
function rotateObject(place) {
var new_image = getNextObject();
document[place].src = new_object;
var recur_call = "rotateObject('"+place+"')";
setTimeout(recur_call, interval);
}
// End -->
</script>
BODY Tag Code
<body OnLoad="rotateObject('rObject')">
<div align="right">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="rObject" width="165" height="135" id="rObject">
<param name="movie" value="services/pics/r_pic01.swf">
<param name="quality" value="high">
<embed src="services/pics/r_pic01.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="165" height="135"></embed>
</object>
</div>
</body>
If anyone knows my mistake, and can help, it'd greatly be appreciated!
Thanks,
Aaron