Thanks, that was what I started out with and ended up with several more changes. I made it good for one image only and set it so the image moves in a straight line (no sine wave). I still don't like how it just cuts off at the edges of my layer/div and want to implement a customizable delay before it flies over again and maybe put in a variable to set the number of flyovers there will be. The layer/div code was moved inside my table.
More work and little time. Being that this is just an enhancement I am moving on with the site and will come back to this later.
PHP Code:
<script language="JavaScript1.2">
//Flying planes - by John Ely
//Modified from: Autumn leaves script- by Kurt Grigg (kurt.grigg@virgin.net)
//Modified by Dynamic Drive for NS6 functionality
//Modified by Jason Wagner for containment & quantity
//visit http://www.dynamicdrive.com for this script
ns=(document.layers)?1:0;
ns6=(document.getElementById&&!document.all)?1:0;
ie=document.all;
delay = 3; //delay between loops in seconds
dismissafter=3;
WinHeight=1;
WinWidth=500;
Ypos = Math.round(Math.random()*WinHeight);
Xpos = Math.round(Math.random()*WinWidth);
Speed= Math.random()*2+1;
Step=Math.random()*0.1+0.05;
function fly(){
sy = Speed*Math.sin(Step);
sx = Speed*2;
Ypos+=sy;
Xpos+=sx;
//wrap the animation back to the left side
if (Xpos > WinWidth){
//setTimeout('reset()',delay*1000);
reset();
} else {
//position the image element
if (ns){
document.layers['sn'].left=Xpos;
document.layers['sn'].top=Ypos;
}
else if (ns6) {
document.getElementById("si").style.left=Xpos;
document.getElementById("si").style.top=Math.min(WinHeight,Ypos);
}
else {
eval("document.all.si").style.left=Xpos;
eval("document.all.si").style.top=Ypos;
}
Step++;
}
//keep the animation going
setTimeout('fly()',100); //execute the script after waiting 1/10 of a second
}
function reset(){
Ypos=Math.round(Math.random()*WinHeight); //reset the y-coordinate
Xpos=-10; //reset the x-coorinate, use - so it flys in
Speed=Math.random()*5+1; //reset the speed
}
//start the animation
if (ie||ns||ns6)
//window.onload=fly
//-->
</script>
Bookmarks