<div id="dragon" style="position: absolute; left: 600px; top: 400px; " onload="timeimgs('9');">
</div>
<script language="JavaScript">
var anim_images=new Array();
//putting drag0 to drag9 png into the anim_images array
for (i=0;i<=10;i++) {
var name;
name=eval("drag" + numb + ".png");
anim_images.push("name");
}
function imgturn(numb) {
if (numb == "9") { // This will loop the image
//getting the image of the array when reach 9
document["demo"].src=anim_images[9];
//starting again with drag0.png?
timeimgs('0');
}
else {
document["demo"].src=anim_images[numb];
timeimgs(numb = ++numb);
}
}
function timeimgs(numb) { // Reusable timer
thetimer = setTimeout("imgturn('" +numb+ "')", 1000);
}
</script>
Right now, it isn’t working yet. it set the drag0.png to 200 width and 200 height. and I want to animate drag0.png to drag9.png continuously.
Any inputs are appreciated.
HTML:
JAVASCRIPT:
Insure that each of your images has same size (width and height) as
DIV#dragonor replaceDIV#dragonwithIMG#dragonhtml element and use IMGsrcproperty instead ofstyle.backgroundImage. Example: http://jsfiddle.net/RK7u9/1/