光标卡在第1帧Flash AS3中

时间:2013-03-05 02:44:25

标签: actionscript-3 flash cursor

每次重新访问第1帧时,都会弹出一个重复的光标。当进入第2帧然后按下后退按钮到第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();

1 个答案:

答案 0 :(得分:1)

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

但是你可以避免以多种方式重新执行代码。例如

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();
相关问题