[英]MouseEvent.CLICK not responding on stage
When I listen to mouse click event on the stage, it seems it's not always responding to my mouse click event. 当我在舞台上听鼠标单击事件时,似乎并不总是响应我的鼠标单击事件。 what I have is:
我所拥有的是:
stage.addEventListener(MouseEvent.CLICK, Test);
function Test(event:MouseEvent):void
{
trace("test");
}
I usually have to click a few times randomly on the stage to get the trace statement. 我通常必须在舞台上随机单击几次以获取trace语句。 I thought when I add this event listener to the stage, it should respond to any mouse click within the swf area, no?
我以为,当我将此事件侦听器添加到舞台上时,它应该响应swf区域内的任何鼠标单击,对吗? Any ideas?
有任何想法吗?
Thanks. 谢谢。
Are you working with Flex? 您正在使用Flex吗? If so, try the following instead:
如果是这样,请尝试以下操作:
mx.core.Application.application.addEventListener(MouseEvent.CLICK, Test);
In Flex adding the listener to stage doesn't seem to work... no idea why. 在Flex中,将侦听器添加到舞台似乎不起作用……不知道为什么。
try a more "loosy" event 尝试更“混乱”的事件
MouseEvent.MOUSE_DOWN
MouseEvent.MOUSE_DOWN
if you want to trigger your event only when user releases the button, try 如果您只想在用户释放按钮时触发事件,请尝试
MouseEvent.MOUSE_UP
MouseEvent.MOUSE_UP
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.