Flex与TitleWindow通信一例及itemRender与父组件的通讯

http://www.pqshow.com/design/jiqiao/200912/12573.html

 

flex itemRender 与父组件的通讯

 

this.parentDocument.reset();//父组件的方法

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
    <mx:Script>
        <![CDATA[
            private function RequestData():void
            {                                
                this.parentDocument.reset();//父组件的方法
                var numStartDate:Number = -1;
                numStartDate = data.numStartDate;
                var numEndDate:Number = -1;        
                numEndDate = data.numEndDate;        
                var obj:Object = new Object();
                obj.token = data.nickName;                
                obj.startDate = numStartDate;
                obj.endDate = numEndDate;
                var requestCurrentPage:Number = HYAgentStaticsSelfModel.getInstance().currentPage    ;    
                obj.pageNo = requestCurrentPage + 1;                
                obj.pageSize = lengthOfpage * pageRequestCount;            
                EventBroadcaster.getInstance().broadcastEvent("EVENT_AGENTSTATICSSELF",obj);
            }    
        
        ]]>
    </mx:Script>
    <mx:LinkButton label="{data.nickName}" click="refeshData();"/>
</mx:HBox>
 

 

main.mxml

 

 

<?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" minWidth="955" minHeight="600">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
		import flash.events.*;
		import mx.managers.PopUpManager;
		import mx.containers.TitleWindow;    
		
		// 响应按钮单击事件,弹出myTitleWindow对话框
		private function openWindow(event:MouseEvent):void {
		// 使用PopUpManager.createPopUp方法弹出myTitleWindow
		var aTitleWindow:MyTitleWindow=MyTitleWindow(PopUpManager.createPopUp(this,MyTitleWindow, true));
		PopUpManager.centerPopUp(aTitleWindow); //居中
		// 注意这里为自定义组件的myObj属性赋值以引用当前MXML文档
		aTitleWindow.myObj = this;
		}
		]]>
	</fx:Script>
	<s:Button label="打开对话框" click="openWindow(event);" x="404" y="24"/>
	<s:Label id="myLabel" text="wait..." width="200" x="375" y="110" fontWeight="bold" fontSize="18" color="#06C9F3"/>
</s:Application>

 MyTitleWindow.mxml

 

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow 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" close="PopUpManager.removePopUp(this);">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:TextInput x="10" y="10" id="myTextInput"/>
	<s:Button x="36" y="74" label="确定" id="myButton"
			   click="closeTitleWindow(event);"/>
	<fx:Script>
		<![CDATA[       
		import mx.managers.PopUpManager;
		import mx.controls.Text;
		
		// 定义一个变量来获取对主应用程序的引用
		public var myObj:Object;
		
		// 该方法用来关闭弹出的TitleWindow 容器.
		private function closeTitleWindow(event:MouseEvent):void {
		myObj.myLabel.text = "您输入的是:" + myTextInput.text;
		myObj.myLabel.setStyle("color",String(cp.selectedColor))
		PopUpManager.removePopUp(this);
		}
		
		private function close(evt:MouseEvent):void{
		
		PopUpManager.removePopUp(this);
		} 
		]]>
	</fx:Script> 
	<s:Button x="96" y="74" label="close" click="close(event);"/>
	<mx:ColorPicker x="10" y="44" id="cp" selectedColor="#F30A0A"/>
</s:TitleWindow>

你可能感兴趣的:(xml,Flex,Flash,Adobe)