AS3 - 如何让鼠标光标点击一个按钮? [英] AS3 - how to get the mouse cursor to click on a button?

查看:133
本文介绍了AS3 - 如何让鼠标光标点击一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

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

Mouse.hide();

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


$ b函数hide_cursor(event:Event):void
{
my_cursor_mc.visible = false;

$ / code $ / pre

我试过使用这个(下面),但是非常粗糙,不得不按下按钮为光标消失然后我能够点击按钮(不是很理想):
$ b $ pre $ stage.addEventListener(MouseEvent。 CLICK,hide_cursor);


解决方案

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

  //禁用游标的鼠标事件
my_cursor_mc.mouseEnabled = false;

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

  //禁用游标的任何子元素的鼠标事件
my_cursor_mc.mouseChildren = false;


In my application i have a mouse cursor which is attached to the mouse. However it will not let me click on buttons within my application which is a big problem for me as buttons are essential in what i need to do.

I am new to AS so any help would be much appreciated!

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;
}

i tried using this (below) but was very glichy and had to press button for cursor to go away THEN i was able to click on the button (not really ideal):

stage.addEventListener(MouseEvent.CLICK, hide_cursor);

解决方案

Sounds like your cursor might be stealing the mouse events for your buttons. In your top level code (or constructor) try adding:

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

If you mouse event has any child objects also add:

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

这篇关于AS3 - 如何让鼠标光标点击一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆