Manual click event trigger in Flex
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);
精彩评论