Click Flex 4 spark ToggleButton component in code
I can't found any property in sparks's ToggleButton that allow me to press it from code. I tested setCurrentState("down") method, but this way button not开发者_运维技巧 dispatching click event i think.
You'll have to manually create a click event and dispatch it to simulate a "click in code". Conceptually something like this:
var clickEvent : MouseEvent = new MouseEvent(MouseEvent.CLICK)
this.myButton.dispatchEvent(clickEvent);
If this doesn't switch the toggle state, you may have to do so manually, and your original answer has that code.
精彩评论