|
-
Apr 2nd, 2003, 11:11 AM
#1
Thread Starter
Fanatic Member
using "for" looping
hi there, the following scripts is for moving an object..
and now I want to make it loop 4 times...how can add a"for looping" to that script
-------this did not work---------
<script language="javascript">
for(var i=1;i<3;i++)
{
moveit()
}
</script>
-------------------
---------------
<html>
<head>
<style>
#piccy{color:green;background-color:yellow;width:80;height:80;}
body{background-color:black;color:yellow;}
</style>
<script>
var delay=10,ver=0, hor=0
function moveit()
{
if(hor<500)
{
piccy.style.left= hor;
hor=hor+5;
setTimeout('moveit()',delay);
}
if(hor==500){moveitd()}
}
function moveitd()
{
if(ver<330)
{
piccy.style.top= ver;
ver=ver+5;
setTimeout('moveitd()',(delay*10));
}
if(ver==330){moveitl()}
}
function moveitl()
{
if(hor>10)
{
piccy.style.left=hor;
hor=hor-5;
setTimeout('moveitl()',(delay+10));
}
if(hor==10){moveity()}
}
function moveity()
{
if(ver>0)
{
piccy.style.top=ver;
ver=ver-5;
setTimeout('moveity()',(delay+10));
}
}
</script>
</head>
<body>
<center>
<form>
<input type="button" value="start" onClick="moveit()">
<br>
</form>
<div id="piccy" style="position: absolute; top: 0px; left: 0px; width: 60px; height:60px;
visibility: visible">
<img src="cilek.gif" height="55" width="55">
</div>
<script language="javascript">
for(var i=1;i<3;i++)
{
moveit()
}
</script>
</body>
</html>
----------------------
thanks indeed
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
|