欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flex回调函数 博客分类: Flex Flex回调函数

程序员文章站 2024-03-17 09:44:34
...

应用场景:父子窗体之间的通信,比如想把弹出窗口中的数据传给弹出该窗体的组件。

 

<?xml version="1.0" encoding="utf-8"?>
<s:Group 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="400" height="300">
<fx:Script>
<![CDATA[
private var _callBackFunction:Function;
public function set callBackFunction(value:Function):void
{
_callBackFunction = value;
}
private function onClick(event:MouseEvent):void{
_callBackFunction.call(null,ti.text);
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<s:TextInput id="ti"/>
<s:Button id="btn" label="Click me" click="onClick(event)" />
</s:VGroup>
</s:Group>

 

 

var myView:MyComponent2 = PopUpManager.createPopUp(this,MyComponent2,false) as MyComponent2;
myView.callBackFunction = callBack;
PopUpManager.centerPopUp(myView);

private function callBack(str:String):void{
trace(str);
}
相关标签: Flex 回调函数