Attach event to a button

In flex there are two ways to attach event to a button control.

First way.

In the button declaration you can specify the function name on the event name.

Second way

You can programatically attach a function to the buttons click event. See example below.

//Attach function to the buttons click event.  

btnAddItem.addEventListener(MouseEvent.CLICK,ShowAddItemWindow);

//Declare the function and implement it.

 private function ShowAddItemWindow(evt:MouseEvent):void

            {

            Alert.show("hello world");

            }
,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share to Facebook Share to Twitter Stumble It Share on Tumblr Digg More...