ActionScript3 导出问题
我刚刚开始使用动作脚本三,我编写了代码来使影片剪辑可以通过击键移动,并编写 HitTest 来运行另一个影片剪辑。当我预览它时,一切正常。但是当我将其发布为 html 时,击键停止工作。其他动画工作正常,只是动作似乎根本没有导出。我该怎么办?
这是代码:
boat1_mc.x = 10
boat1_mc.x = 10
stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent) :void
{
switch(event.keyCode)
{
case Keyboard.RIGHT: boat1_mc.x += 5
break;
case Keyboard.LEFT: boat1_mc.x -= 5
break;
default :
break;
}
if(boat1_mc.hitTestObject(tree_mc))
{
tree_mc.gotoAndPlay(2);
boat1_mc.x = 10
boat1_mc.x = 10
}
}
感谢您的帮助!
I have just started using actionscript three and I wrote code to make a movieclip moveable through keystrokes and a HitTest to make another movie clip run. When I preview it it all works fine. But when I publish it to html the key strokes stop working. The other animations are working fine, just the actions seem to be not exporting at all. What do I dooo?
Here is the code:
boat1_mc.x = 10
boat1_mc.x = 10
stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent) :void
{
switch(event.keyCode)
{
case Keyboard.RIGHT: boat1_mc.x += 5
break;
case Keyboard.LEFT: boat1_mc.x -= 5
break;
default :
break;
}
if(boat1_mc.hitTestObject(tree_mc))
{
tree_mc.gotoAndPlay(2);
boat1_mc.x = 10
boat1_mc.x = 10
}
}
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能太简单了,但是您是否单击了 swf 使其获得焦点?当您第一次加载页面时,按键会转到页面本身;您需要在 swf 中单击才能通过按键到达那里。
This may be too simple, but did you click in the swf to give it focus? When you first load the page keypresses go to the page itself; you need to click in the swf for keypresses to go there.