有高手知道该怎样解决吗??(在线)
lijn 2002-11-22 04:22:06 我想在页面中控制一幅gif的走动.但是好象没有什么反应啊. 能帮我看看这个程序那里有错吗?
<html>
<script>
function init()
{
a=aa.style;
a.xpos=parseInt(a.left);
a.ypos=parseInt(a.top);
a.angle=0;
a.activeleft=0;
a.activeright=0;
a.activemove=0;
move();
document.onkeydown=keyDown
document.onkeyup=keyUp
}
function keyDown(e)
{
var iekey=window.event.keyCode
if (iekey==100 && !a.activeleft)
{
if (a.activeright)
a.activeright=0;
a.activeleft=1;
turnLeft();
}
if (iekey==102 && !a.activeright)
{
if (a.activeleft)
a.activeleft=0;
a.activeright=1;
turnRight()
}
if (iekey==101 && !a.activemove)
{
a.avtivemove=1;
}
}
function keyUp(e)
{
var iekey=window.event.keyCode
if (iekey==100)
a.activeleft=0;
if (iekey==102)
a.activeright=0;
if (iekey==101)
a.activemove==0;
}
function turnLeft()
{
if (a.activeleft)
{
a.angle+=15
if (a.angle==360)
a.angle=0
setTimeout("turnLeft()",20)
}
}
function turnRight()
{
if (a.activeright)
{
a.angle-=15
if (a.angle==-10)
a.angle=355
setTimeout("turnRight()",20)
}
}
function move()
{
if (a.activemove)
{
a.xpos+=15*Math.cos(a.angle*Math.PI/180)
a.ypos-=15*Math.sin(a.angle*Math.PI/180)
a.left=a.xpos
a.top=a.ypos
}
setTimeout("move()",20)
}
</script>
<body onload="init()">
</p>
<div id="aa"style="position:absolute;left:50;top:100;width:30">
<img src="f:/123/1.gif" width=30 height=30 boeder=0>
</div>
</body>
</html>