2012-12-13 55 views
1

在我的应用程序中,我有一个连接鼠标的鼠标光标。但是,它不会让我点击我的应用程序中的按钮,这对我来说是一个很大的问题,因为按钮对于我需要做的事情至关重要。AS3 - 如何让鼠标光标点击按钮?

我是新来的AS,所以任何帮助将不胜感激!

stage.addEventListener(MouseEvent.MOUSE_MOVE, draw_cursor); 
stage.addEventListener(Event.MOUSE_LEAVE, hide_cursor); 

Mouse.hide(); 

function draw_cursor(event:MouseEvent):void 
{ 
    my_cursor_mc.visible = true; 
    my_cursor_mc.x = event.stageX; 
    my_cursor_mc.y = event.stageY; 
} 


function hide_cursor(event:Event):void 
{ 
    my_cursor_mc.visible=false; 
} 

我试图用这个(下同),但很glichy,不得不按下按钮,光标消失,那么我能够按一下按钮(不甚理想):

stage.addEventListener(MouseEvent.CLICK, hide_cursor); 
+0

支持适当的自定义原生的鼠标光标是在Flash Player 10.2增加。你可以在这里了解它:http://www.adobe.com/devnet/flashplayer/articles/native-mouse-cursors.html –

+0

非常优秀的链接,感谢分享。我会推荐使用本地鼠标光标作为亚当建议。 – ToddBFisher

+0

[actionscript 3事件中的自定义光标可能重复不起作用](https://stackoverflow.com/questions/2528709/custom-cursor-in-actionscript-3-event-doesnt-work) –

回答

3

听起来就像你的光标可能在窃取你的按钮的鼠标事件。在您的顶级代码(或构造函数)尝试添加:

// Disable mouse events for cursor  
my_cursor_mc.mouseEnabled = false; 

如果你的鼠标事件有任何子对象也补充:

// Disable mouse events for any children of the cursor 
my_cursor_mc.mouseChildren = false; 
+0

工作完美,谢了哥们! –