有高手知道该怎样解决吗??(在线)

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>
...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijn 2002-11-22
  • 打赏
  • 举报
回复
有谁能帮我啊??
qiushuiwuhen 2002-11-22
  • 打赏
  • 举报
回复
a.avtivemove=1
=>
a.activemove=1

if (iekey==101 && !a.activemove)a.activemove=1;

87,955

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧