|
-
Dec 9th, 2004, 01:41 PM
#1
Thread Starter
Addicted Member
How do i do animation in Javascript?
I have never done animation in javascript and want to know how. What I want to learn how to do is basically take a ball image and make it go around the four corners of the broswer window. Anybody know how?
-
Dec 9th, 2004, 02:49 PM
#2
Frenzied Member
Re: How do i do animation in Javascript?
http://www.google.com/search?q=javas...utf-8&oe=utf-8
Google does. Come back here when you run into errors with the code.
-
Dec 9th, 2004, 09:30 PM
#3
Thread Starter
Addicted Member
Re: How do i do animation in Javascript?
Ok, here is my code. I can get the ball to move back and forth but how do I get it to go up and down? Here is what I mean...What i want as the end result is for it to go all the way around the screen, and, until the user clicks the stop action button, it will just keep going.
I know i can change from left and right:
Code:
document.all.BallID.style.left = currentPos + moving;
top up and down
Code:
document.all.BallID.style.top = currentPos + moving;
but how to get it to go around and round and round?(follow the arrows)
--<-
:-- :
:-- :
v--^
:-- :
:-- :
-->-
Code:
<html>
<head>
<title>My animation</title>
<SCRIPT LANGUAGE = "JavaScript1.2">
<!--
var moving=0;
var movingamount =10
function moveBall(currentPos){
moving += movingamount;
document.all.BallID.style.left = currentPos + moving;
if(moving > 670)
{
movingamount = -10;
}
if(moving < 0)
{
movingamount = 10;
}
}
-->
</script>
</head>
<body topmargin=0 leftmargin="0">
<SPAN ID=BallID STYLE="position:absolute; left=50; top=50"><img name = "8Ball" src="eightball.gif"></SPAN>
<form name=sample2>
<input type="button" value=" Move Eightball " name="move" onClick="movement=setInterval('moveBall(40)', 50);">
<input type="button" value=" Stop action " name="move" onClick="clearInterval(movement);">
</form>
</body>
</html>
Last edited by ddmeightball; Dec 9th, 2004 at 09:34 PM.
-
Dec 12th, 2004, 03:42 PM
#4
Thread Starter
Addicted Member
Re: How do i do animation in Javascript?
Can anyone help me with this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|