首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex 自定义组件(TitleWindow)与组件(TitleWindow)其间交互传值

2012-11-22 
flex 自定义组件(TitleWindow)与组件(TitleWindow)之间交互传值父窗体:A.mxml子窗体:B.mxml想实现把子窗体

flex 自定义组件(TitleWindow)与组件(TitleWindow)之间交互传值

父窗体:A.mxml子窗体:B.mxml想实现把子窗体B的值传到A中首先:在父窗体A中添加一个监听[Bindable]private var targetArr:ArrayCollection=null;//A中的变量 private var b:B=new B();private function  showB():void{     b=new B();    PopUpEffect.show(b,DisplayObject(this.parentApplication),true);    formular.removeEventListener("b_click ",getBvalues );    formular.addEventListener("b_click ",getBvalues );}private function getBvalues (event:Event):void{          if(targetArr!=null){                targetArr.removeAll();//先清空,后赋值           }          this.targetArr=b.targetArr; //B的targetArr赋值给A的targetArr          PopUpEffect.remove(b);//关闭B窗体 }其次:在子窗体B中[Bindable] public var targetArr:ArrayCollection=null; //子窗体B中的变量,注意是public 在一个方法内写入以下代码,分发事件。dispatchEvent(new Event("b_click"));注意分发事件前,请给B中的变量赋值,要不就是null了。例如:  private function queryTargetHandle(event:ResultEvent):void{        targetArr=ArrayCollection(event.result);         dispatchEvent(new Event("b_click "));     }本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xuhuanchao/archive/2010/04/04/5449410.aspx
?

热点排行