<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>i have a script which&nbsp;animates a layer to a 
given set of coords on the page (below). (it does it in&nbsp;as straight a line 
as possible, and slows down the closer it gets to final position.)&nbsp;It can 
be used for multiple layers at once. I was trying to come up with a way of 
detecting when all layers being animated&nbsp;had arrived at their final 
location - ie. a script that constantly checks whether they have or not 
-&nbsp;but i cant think of a way of doing it. it has to be a little cleverer 
than doing an else statement on the "recall" part if it's to&nbsp;detect 
multiple&nbsp;"animation&nbsp;complete" events.&nbsp;does anyone have any 
ideas?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>possibilities:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>1)create a variable in an array for each animation 
that is started. delete the variable for the animation when it finishes. have 
the script check for when _array_.length==0. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>2)increase the value of a variable by one each time 
a new animation is started and decrease it's value by one each time it is 
completed</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>problems:</FONT></DIV>
<DIV><FONT face=Arial size=2>- i don't have a clue how i could pull either of 
these off</FONT></DIV>
<DIV><FONT face=Arial size=2>- deleting a variable that is part of an array does 
not decrease _array_.length - or at least i dont know how to.</FONT></DIV>
<DIV><FONT face=Arial size=2>- the animation is triggerred by a user event, if 
they restart it before the animation is finished, neither of these ideas will 
ever know when the animation has finished.the same anim will have 
started&nbsp;twice, but finished&nbsp;only once</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; - so then i thought how about 
something that uses a dynamically assigned variable of an object (like the way 
i'm using animTimer object), combined with number 1 above&nbsp;and check for 
when it's length is zero, but animTimer.length (or similar) always returns 
undefined :-(</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Dash</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;var animTimer = new Object();<BR>function 
slideTo(layerID,finalLeft,finalTop){</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;eval("clearTimeout(animTimer."+layerID+")");&nbsp;//incase the 
animation is restarted half-way through</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;var 
initLeft=parseInt(document.getElementById(layerID).style.left);&nbsp;//find out 
where<BR>&nbsp;var 
initTop=parseInt(document.getElementById(layerID).style.top);&nbsp;//the layer 
is now</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;var 
newLeft=finalLeft-Math.round(0.68*(finalLeft-initLeft));&nbsp;//calculate new 
coords of the element<BR>&nbsp;var 
newTop=finalTop-Math.round(0.68*(finalTop-initTop));&nbsp;//it'll move a 
percentage of the distance that it currently is from its final 
position</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;document.getElementById(layerID).style.left = 
newLeft; //move the layer to its calculated coords</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;document.getElementById(layerID).style.top = 
newTop;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;if((newLeft==initLeft) &amp;&amp; 
(newLeft!=finalLeft)){<BR>&nbsp;&nbsp;moveTo(layerID,finalLeft,initTop);&nbsp;&nbsp;//if 
its not going to be moved but is not at its final destination, put it 
there<BR>&nbsp;&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;if((newTop==initTop) &amp;&amp; 
(newTop!=finalTop)){<BR>&nbsp;&nbsp;moveTo(layerID,initLeft,finalTop)&nbsp;&nbsp;//same 
again but for y coord<BR>&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;if((finalLeft!=initLeft) || 
(finalTop!=initTop)){<BR>&nbsp;&nbsp;eval("animTimer."+layerID+'=setTimeout("slideTo('+"'"+layerID+"',"+finalLeft+","+finalTop+')"'+",30)"); 
//recall function if it's not at it's final 
destination<BR>&nbsp;&nbsp;}<BR>}<BR></FONT></DIV></BODY></HTML>