Follow me Stepbystep Flex tutorial

Source: Internet
Author: User
Tags definition event listener

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.