Demo's Operation effect:
The source code is as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml" layout= "Absolute" Creationbtnhandler (event) ">
<mx:Script>
<! [cdata[
Import Mx.controls.Alert;
Private Function Test1clickhandler (e:mouseevent): void {
Mxmlreginp.text= "Registration event in MXML";
Alert.show (E.currenttarget.tostring ());
}
Private Function Creationbtnhandler (e:event): void {
Eventtes3btn.addeventlistener (Mouseevent.click, Test3clickhandler);
}
Private Function Test3clickhandler (e:event): void {
mxmlreginp.text= "ActionScript Registration event listener";
}
]]>
</mx:Script>
<mx:button x= "y=" label= "MXML" id= "eventtes1btn" click= "Test1clickhandler" (event) fontsize= "Width=" "140"/>
<mx:button x= "207" y= "label=" MXML definition Create online event "id=" Eventtes2btn "click=" mxmlreginp.text= ' MXML ' Fontsize= "Width=" "185"/>
<mx:textinput x= "y=" "id=" Mxmlreginp "fontsize=" "width=" 333 "enabled=" true "color=" #13E409 "fontweight=" Bold "fontstyle=" italic "editable=" false/>
<mx:button x= "y=" 127 "label=" ActionScript registered event Listener "fontsize=" "width=" "333" id= "eventtes3btn"/>
</mx:Application>
This demo demonstrates Flex's three event modes, which are the names written on the button:
1, MXML in the event of registration;
2. Create the online event in the MXML definition;
3, ActionScript registration event listeners;
The 2nd way is for everyone to understand, the author does not recommend that the reader use the 2nd way in the actual application of the project, this way the code is blunt, difficult to maintain.
You can do this demo, the next lecture on the event will be some theoretical supplement.
Article Source: http://wangyisong.javaeye.com/blog/373563