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.

 del.icio.us  Stumbleupon  Technorati  Digg 

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments
  • No comments exist for this entry.
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.