actionscript 3 -光标卡在Flash AS3的第1帧



每次重新访问第1帧时,都会弹出一个重复的光标。当转到第二帧,然后按后退键回到第一帧时,光标会被卡住,但也会出现一个新的光标,这意味着我在一帧中有两个光标。

请帮忙好吗?

谢谢

stage.addChild(pencil);
pencil.mouseEnabled = false;
pencil.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
function fl_CustomMouseCursor(event:Event)
    pencil.x = stage.mouseX;
    pencil.y = stage.mouseY;
Mouse.hide();

在框架中编写代码-不好的做法。

但是你可以用很多方法避免重新执行代码。例如

var executed:Boolean;
if (executed) return;
executed = true;
// ----------------
stage.addChild(pencil);
pencil.mouseEnabled = false;
pencil.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
function fl_CustomMouseCursor(event:Event)
    pencil.x = stage.mouseX;
    pencil.y = stage.mouseY;
Mouse.hide();

最新更新