简体   繁体   English

MouseEvent.CLICK在舞台上没有响应

[英]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.

相关问题 调用MouseEvent.CLICK后,AS3 MouseEvent.MOUSE_MOVE事件停止响应 - AS3 MouseEvent.MOUSE_MOVE event stops responding after MouseEvent.CLICK call img上的AS3 MouseEvent.CLICK无法正常工作 - AS3 MouseEvent.CLICK on img not working Flash ActionScript 3.0按钮单击全局MouseEvent.CLICK - Flash ActionScript 3.0 button click over global MouseEvent.CLICK 操作脚本3 - 在MouseEvent.CLICK上创建一个退出app / progam按钮 - Action Script 3 - Make a quit app/progam button on MouseEvent.CLICK ActionScript 3.0上MouseEvent.CLICK和MouseEvent.MOUSE_DOWN的差异是什么 - What is the diffrence in MouseEvent.CLICK & MouseEvent.MOUSE_DOWN on ActionScript 3.0 如何在Adoble Flash CS6中同时使用MouseEvent.ROLL_OUT和MouseEvent.CLICK? - How do i use MouseEvent.ROLL_OUT and MouseEvent.CLICK at same time in Adoble Flash CS6? 如何在AS3中创建自定义MouseEvent.CLICK事件(将参数传递给函数)? - How to create custom MouseEvent.CLICK event in AS3 (pass parameters to function)? 如何在一帧.fla中刷新MouseEvent.CLICK上的动态文本字段? - How do I refresh a dynamic text field on MouseEvent.CLICK in a one-frame .fla? AS3 Video MouseEvent单击无法正常工作 - AS3 Video MouseEvent Click not working 动作脚本单击背景/阶段 - Actionscript click on background/stage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM