How to pass an individual property to an event handler
I usually just pass the entire Event object to my event listeners however it is possible to pass an individual property to an event handler.
First you have to set up the handler something like this:
private function handleThis(val:String):void {
trace(val);
}
Now since your handler is expecting a string you just pass it one like this:
<mx:Button id="submit" label="Submit" click="handleThis(event.currentTarget.id)"/>
In this case I'm passing the id of the button to the event handler but you can pass pretty much whatever property that Flex can access.
First you have to set up the handler something like this:
private function handleThis(val:String):void {
trace(val);
}
Now since your handler is expecting a string you just pass it one like this:
<mx:Button id="submit" label="Submit" click="handleThis(event.currentTarget.id)"/>
In this case I'm passing the id of the button to the event handler but you can pass pretty much whatever property that Flex can access.






Comments