Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 ActionScript3导出问题_Actionscript 3_Export_Keystroke - Fatal编程技术网

Actionscript 3 ActionScript3导出问题

Actionscript 3 ActionScript3导出问题,actionscript-3,export,keystroke,Actionscript 3,Export,Keystroke,我刚刚开始使用ActionScript3,我编写了代码,通过击键和HitTest使movieclip可以移动,从而运行另一个电影剪辑。当我预览它时,一切都很好。但当我将其发布到html时,按键就停止工作了。其他动画工作正常,只是动作似乎根本没有导出。我该怎么办 代码如下: boat1_mc.x = 10 boat1_mc.x = 10 stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPressed); function keyPressed

我刚刚开始使用ActionScript3,我编写了代码,通过击键和HitTest使movieclip可以移动,从而运行另一个电影剪辑。当我预览它时,一切都很好。但当我将其发布到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

}
}

谢谢你的帮助

这可能太简单了,但您是否在swf中单击以获得焦点?第一次加载页面时,按键转到页面本身;你需要点击swf,按键才能进入那里。

是的-我同意-需要获得焦点。