Flex callback Function Application Example _flex

Source: Internet
Author: User
A callback function is a function called by a function pointer. If you pass the pointer (address) of a function to another function as an argument, when the pointer is used to call the function it points to, we say this is a callback function. The callback function is not called directly by the implementation method of the function, but is called by another method when a particular event or condition occurs, and is used to correspond to the event or condition.

Below or through the way of the Code, to implement a callback function application.

Flexcallback.mxml
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<s:application xmlns:fx= "http://ns.adobe.com/mxml/2009"
Xmlns:s= "Library://ns.adobe.com/flex/spark"
xmlns:mx= "Library://ns.adobe.com/flex/mx" width= "100%" height= "100%" >

<fx:Script>
<! [cdata[

Import Flash.external.ExternalInterface;
Import flash.system.Security;
Import Mx.controls.Alert;
Import mx.events.FlexEvent;
public var callbackinfo:string = "";

Public Function Dosend (): void{

var Call:flexapp = new Flexapp ("Hello", callBack);

}

Public function CallBack (info): void{

Alert.show (info);

}

]]>
</fx:Script>

<fx:Declarations>
<!--place non-visual elements (such as services, value objects) here-->
</fx:Declarations>
<s:panel width= "100%" height= "100%" >

<s:button label= "Send" click= "Dosend ()" >

</s:Button>


</s:Panel>

</s:Application>

Flexapp class of your own definition
Copy Code code as follows:

Package
{
public class Flexapp
{

Public Function Flexapp (param:string,func:function)
{

Func.call (NULL, "received");
}
}
}

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.