PDA

View Full Version : easier way of typing code + loop


chris_angell
07-12-2002, 06:08 PM
I am trying to animate several divs that animate at different intervals, but I can't work out how to ?? I can do it if I copy the code and give it a different function name..
etc animate1();animate2(); and so on.. this is a crap long way to do it, I would like to know an easier way to run animation divisions from the same function but going of at different set times ???? and also if I can loop those specific animations, say three times ??? so they repeat ????

here is my code,

<script>
var y=0;
var yMax1=436;
var yMax2=300;

function animateIt(){
if(y<=yMax1){
document.getElementById('animatedDiv').style.top=y;
document.getElementById('animatedlineDiv').style.top=y;
y=y+60;
setTimeout("animateIt()",10);
}
}
</script>


<input type="button" value="Move!" onClick="animateIt(1)">
<div id="animatedDiv"><img src="images/_black_arrow.gif" width="85" height="85"></div>
<div id="animatedlineDiv">
<img src="images/_black_lines.gif" width="128" height="2"></div>


thank you ... I hope it make sense ?? :thumbsup:

chris_angell
07-15-2002, 06:10 PM
I ran the script above but and it comes up with errors, I have tried using all my powers, to correct the problem ??

but

sadly these powers do not work, can anyone see if there is a stupid reason why it may not be working ?????


thanks :thumbsup: