2013-03-05 41 views
0

每次我重新访问第1帧时,都会弹出一个重复的光标。当进入第2帧然后点击返回按钮到第1帧时,光标会卡住,但也会出现一个新的光标,这意味着我在一帧中有两个光标。光标卡在第1帧中Flash AS3

请帮忙吗?

谢谢

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

您是否正在创建自定义光标,还是仅仅是默认操作系统光标多次出现? – Marcela 2013-03-05 03:38:34

+1

提供您的代码或您正在尝试执行的示例。 – Gio 2013-03-05 06:47:47

+0

这是一个自定义光标 – Jen 2013-03-05 14:17:07

回答

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();