开发者

Manual click event trigger in Flex

开发者 https://www.devze.com 2023-01-31 15:50 出处:网络
How to dispatch an click event : for example <mx:Button id=\"btn\" click=开发者_运维百科\"someFunction();\">

How to dispatch an click event :

for example <mx:Button id="btn" click=开发者_运维百科"someFunction();">

by manual event dispatch how to call that someFunction();


If all you want to do is call the handler without clicking the button, just do this somewhere in your ActionScript code:

someFunction();

In your sample, you aren't passing the event parameter to the function. But, if you want to do that, you'll have to create your own MouseEvent object. Something like this:

var myFakeMouseEvent: MouseEvent = new MouseEvent(MouseEvent.CLICK);
// set other properties on the mouse event
someFunction(myFakeMouseEvent);

If you want to dispatch the click event without clicking the buttonn, you can do this:

var myFakeMouseEvent: MouseEvent = new MouseEvent(MouseEvent.CLICK);
// set other properties on the mouse event
objectToDispatchEvent.dispatchEvent(myFakeMouseEvent);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号