Similar to the below in javascript:
与javascript中的以下内容类似:
<input id="target" type="button" onclick="..." />
<script>
document.getElementById('target').click();
</script>
3 个解决方案
#1
1
You can use dispatchEvent function : http://livedocs.adobe.com/flex/3/html/help.html?content=events_07.html
您可以使用dispatchEvent函数: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
您应该在触发之前创建click事件事件的新实例
#2
0
package
{
import flash.display.DisplayObject;
import flash.events.MouseEvent;
public class ClickEventExample
{
public static function dispatchClickEventFrom(something:DisplayObject):void
{
something.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
#3
0
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.
有什么意义呢?在这种情况下,我建议使用自定义事件,因此您不要将自己与MouseEvent.CLICK完全混淆。
if, like ivo suggests, you want to fire an event when the user first rolls over your clip, this should get you started:
如果像ivo建议的那样,当用户第一次翻阅剪辑时你想要发起一个事件,这应该让你开始:
myClip.addEventListener( MouseEvent.ROLL_OVER, handleFirstMouseOver );
function handleFirstMouseOver( e:MouseEvent ) : void
{
dispatchEvent( new Event('mySpecialEvent', true ) );
myClip.removeEventListener( MouseEvent.ROLL_OVER, handleMouseOver );
}
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.
如果(我不假设你是:))你试图伪造点击以绕过弹出窗口阻止程序或进入全屏模式或其他东西,然后再想一想,因为玩家会识别出这样的事件并非实际上是由用户产生的输入。
#1
1
You can use dispatchEvent function : http://livedocs.adobe.com/flex/3/html/help.html?content=events_07.html
您可以使用dispatchEvent函数: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
您应该在触发之前创建click事件事件的新实例
#2
0
package
{
import flash.display.DisplayObject;
import flash.events.MouseEvent;
public class ClickEventExample
{
public static function dispatchClickEventFrom(something:DisplayObject):void
{
something.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
#3
0
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.
有什么意义呢?在这种情况下,我建议使用自定义事件,因此您不要将自己与MouseEvent.CLICK完全混淆。
if, like ivo suggests, you want to fire an event when the user first rolls over your clip, this should get you started:
如果像ivo建议的那样,当用户第一次翻阅剪辑时你想要发起一个事件,这应该让你开始:
myClip.addEventListener( MouseEvent.ROLL_OVER, handleFirstMouseOver );
function handleFirstMouseOver( e:MouseEvent ) : void
{
dispatchEvent( new Event('mySpecialEvent', true ) );
myClip.removeEventListener( MouseEvent.ROLL_OVER, handleMouseOver );
}
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.
如果(我不假设你是:))你试图伪造点击以绕过弹出窗口阻止程序或进入全屏模式或其他东西,然后再想一想,因为玩家会识别出这样的事件并非实际上是由用户产生的输入。