如何在actionscript/flex3中手动触发点击事件?
类似于 JavaScript 中的以下内容:
<input id="target" type="button" onclick="..." />
<script>
document.getElementById('target').click();
</script>
Similar to the below in javascript:
<input id="target" type="button" onclick="..." />
<script>
document.getElementById('target').click();
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用dispatchEvent函数:
http://livedocs.adobe.com/flex/3 /html/help.html?content=events_07.html
您应该在触发之前创建 click 事件的新实例
You can use dispatchEvent function :
http://livedocs.adobe.com/flex/3/html/help.html?content=events_07.html
You should create a new instance of the click event event before firing
这有什么意义呢?我建议在这种情况下使用自定义事件,这样您就不会因为
MouseEvent.CLICK
根本不代表点击而感到困惑。如果,就像 ivo 建议的那样,您想在用户第一次滚动您的剪辑时触发一个事件,这应该可以帮助您开始:
如果(并且我不假设您是:))您正在尝试伪造一个 CLICK 来绕过弹出窗口-up 拦截器或进入全屏模式或其他东西,然后再想一想,因为玩家会识别出此类事件实际上并非由用户输入产生。
what is the point of this? i would recommend using a custom event in this case, so you do not confuse yourself with
MouseEvent.CLICK
not representing a click at all.if, like ivo suggests, you want to fire an event when the user first rolls over your clip, this should get you started:
If (and I am not assuming you are :) ) you are trying to fake a CLICK to get around pop-up blockers or enter FullScreen mode or something, then think again, because the player will recognize such events as not actually spawned from user input.