So, I'm looking at the following code. I've implemented it into my site and it's working fine, however, i'm now after it duplicated a couple of seconds later, at a different part of the screen. I'm currently struggling with multiple functions onload. How would I duplicate this code to have another moving image follow this one?
Thanks in Advance
Code:
<html>
<head>
<title>Moving Image Examplee</title>
<style type="text/css">
<!--
#BearPaww { position: relative; visibility: hidden }
-->
</style>
<script language="JavaScript">
<!--
var thePaww;
var yPos = 0;
var xPos = 0;
var dSign = 1;
function doFancyBearPaww()
{
if ( document.getElementById )
thePaww = document.getElementById("BearPaww");
else if ( document.layers )
thePaww = document.layers["BearPaww"];
else if ( document.all )
thePaww = document.all.item("BearPaww");
if ( thePaww )
{
hideObj( thePaww );
var now = new Date();
var secs = now.getSeconds() % 6;
if ( secs < 12 )
doBottomToTop();
else if ( secs < 12 )
doTopToBottom();
else if ( secs < 12 )
doRightToLeft();
else
doReveal();
}
}
function doFancyBearPaw()
{
if ( document.getElementById )
thePaw = document.getElementById("BearPaw");
else if ( document.layers )
thePaw = document.layers["BearPaw"];
else if ( document.all )
thePaw = document.all.item("BearPaw");
if ( thePaw )
{
hideObj( thePaw );
var now = new Date();
var secs = now.getSeconds() % 6;
if ( secs < 12 )
doBottomToTop();
else if ( secs < 12 )
doTopToBottom();
else if ( secs < 12 )
doRightToLeft();
else
doReveal();
}
}
function moveObjTo( obj, x, y )
{
if ( ! obj.style )
{
obj.top = y;
obj.left = x;
}
else
{
obj.style.top = y + "px";
obj.style.left = x + "px";
}
}
function showObj( obj )
{
if ( ! obj.style )
obj.visibility = "visible";
else
obj.style.visibility = "visible";
}
function hideObj( obj )
{
if ( ! obj.style )
obj.visibility = "hidden";
else
obj.style.visibility = "hidden";
}
function doRightToLeft()
{
xPos = 500;
dSign = 1;
moveObjTo( thePaww, xPos, yPos );
showObj( thePaww );
moveHoriz();
}
function doLeftToRight()
{
xPos = 500;
dSign = -1;
moveObjTo( thePaww, (xPos * dSign), yPos );
showObj( thePaww );
moveHoriz();
}
function moveHoriz()
{
var dec = Math.sqrt(xPos);
xPos -= dec;
if ( 0 < xPos )
{
moveObjTo( thePaww, (xPos * dSign), yPos );
setTimeout( "moveHoriz()", 40 );
}
else
{
moveObjTo( thePaww, 0, 0 );
}
}
function doBottomToTop()
{
yPos = 700;
dSign = 1;
moveObjTo( thePaww, xPos, yPos );
showObj( thePaww );
moveVert();
}
function doTopToBottom()
{
yPos = 200;
dSign = -1;
moveObjTo( thePaww, xPos, -yPos );
showObj( thePaww );
moveVert();
}
function moveVert()
{
var dec = Math.sqrt(yPos/2);
yPos -= dec;
if ( 0 < yPos )
{
moveObjTo( thePaww, xPos, yPos * dSign );
setTimeout( "moveVert()", 50 );
}
else
{
moveObjTo( thePaww, 0, 0 );
}
}
function doFootPrints()
{
yPos = 700;
xPos = 25;
moveObjTo( thePaww, xPos, yPos );
showObj( thePaww );
setTimeout( "moveFootPrint()", 50 );
}
function moveFootPrint()
{
yPos -= 75;
xPos *= -1;
if ( 0 < yPos )
{
moveObjTo( thePaww, xPos, yPos );
setTimeout( "moveFootPrint()", 400 );
}
else
{
moveObjTo( thePaww, 0, 0 );
}
}
function doReveal()
{
if ( ! thePaww.filters )
{
doLeftToRight();
}
else
{
thePaww.style.visibility = "hidden";
thePaww.filters[0].Apply();
thePaww.filters.item(0).transition = 23;
thePaww.style.visibility = "visible";
thePaww.filters[0].Play();
}
}
//-->
</script>
</head>
<body onload="doFancyBearPaww()">
<div align="center">
<div id="BearPaww" name="BearPaww"
style="filter: revealTrans(duration=3.0, transition=23); height:100; width:80;">
<img src="http://www.mitch.bigyetimedia.com/wp-content/uploads/2012/03/What-if-Button-singular2.png" border="0" noresize="true" alt="aperture patch post" class="mouseover" data-oversrc="http://www.mitch.bigyetimedia.com/wp-content/uploads/2012/03/What-if-Button-Surround-21.png" class="mouseout" data-oversrc="http://www.mitch.bigyetimedia.com/wp-content/uploads/2012/03/What-if-Button-singular2.png"/></a>
</div>
</div>
</body>
</html>
As I'm a bit of a noob, i've managed to get the three images to float in, from the bottom, in 'near' the positions that I would like them too. However, I'm working under 'absolute' in px and wonder what would happen, as I want the images symmetrical with the center of the screen, if the viewer has a different screen size. How do I set the first image to enter 'center' and the other images to be 'relative' to it?
Bookmarks