PDA

View Full Version : animeishun



tintinfreak
01-07-2006, 02:33 PM
I tried to create an animation but it didn't work!


Here is the code:
***


<html>
<head>
<script language="javascript">

one=new Image()
one.src="1.gif"
two=new Image()
two.src="2.gif"
three=new Image()
three.src="3.gif"

pic= new Array()
pic[0]=one.src
pic[1]=two.src
pic[2]=three.src

var a=0
var x

function animation()
{
clearTimeout(x)
document['tmuna'].src=pic[a]
a++
if(a>2)
a=0
x=setTimeout('animation()',1000)
}
</script>
</head>
<body onload="animation()">
<img name="tmuna" src="1.gif">
</body>
</html>
***


tintinfreak

jscheuer1
01-08-2006, 06:56 AM
There really is nothing fatally wrong with your code. Works fine as is in FF and IE. Your choice of images is a bit odd though. If you want it to look like an animation, each frame (image) must follow logically from the previous one in a way which simulates the type of movement you want. Yours goes from a blank line to a line with one dot then to a line with two dots then back to a blank line and on and on. If you want to simulate movement, go from a blank line to one with one dot to another with one dot but in another location than the first dot. These things are better done using animated .gifs though, less overhead:

210

tintinfreak
01-10-2006, 11:39 AM
There really is nothing fatally wrong with your code. Works fine as is in FF and IE. Your choice of images is a bit odd though. If you want it to look like an animation, each frame (image) must follow logically from the previous one in a way which simulates the type of movement you want. Yours goes from a blank line to a line with one dot then to a line with two dots then back to a blank line and on and on. If you want to simulate movement, go from a blank line to one with one dot to another with one dot but in another location than the first dot. These things are better done using animated .gifs though, less overhead:

210



Thanks