flex day 3-html和window组件

air的html组件,但是html的显示出来怪怪的

	<s:layout>
		<s:VerticalLayout/>
	</s:layout>
	<mx:ControlBar width="100%">
		<s:Button label="&lt;Back" click="content.historyBack();"/>
		<mx:Button label="Forward &gt;" click="content.historyForward();"/>
		<mx:TextInput id="address" text="{content.location}" width="100%"/>
		<mx:Button label="GO" click="content.location = address.text"/>
	</mx:ControlBar>
	<mx:Canvas width="100%" height="100%">
		<mx:HTML id="content" location="http://www.163.com" />
	</mx:Canvas>

接着就是window组件了。window组件很是神奇,其实就是打开一个新的窗口。

但是解决了我昨天的一个疑问,我想调用的另外一个B.mxml,我把那个B.mxml做成一个组件,

基于mx.core.Window,这样就能调用了,当作是一个window打开就是了。然后给newWindow

增加事件监听,这样可以在打开新窗口的时候隐藏旧窗口

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="placeWindow()">
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.AIREvent;
			
			import spark.components.Window;
			private function placeWindow():void{
				this.nativeWindow.x = 200;
				this.nativeWindow.y = 200;
				
			}
			private function onCloseWindow():void{
				Alert.show("close window");
			}
			
			private function newWindow():void{
				var newWindow:Window = new myWindowCompnent;

				//newWindow.systemChrome = NativeWindowSystemChrome.NONE;
				//newWindow.transparent = true;
				newWindow.title = "new WINDOW";
				newWindow.width = 400;
				newWindow.height =  400;
				newWindow.open(true);
				newWindow.alpha = .9;
				
				newWindow.addEventListener(Event.CLOSING,showWindow);
			}
			private function hideWindow():void{
				this.nativeWindow.visible = false;
			}
			private function showWindow(evt:Event):void{
				this.nativeWindow.visible = true;
				
			}
		]]>
	</fx:Script>
	<mx:Label text="HI My Friend" horizontalCenter="0" verticalCenter="0"/>
	<s:Button label="new window" click="newWindow()" mouseDown="hideWindow()"/>
</s:WindowedApplication>

 

另myWindowCompnent的码是基于filesystem的

<s:Window 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:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
	<mx:HDividedBox>
		<mx:FileSystemTree id="tree"
						   width="200" height="100%" direction="{new File('c:\\')}"
						   enumerationMode="directoriesOnly"
						   change="dataGrid.directory = File(tree.selectedItem);"/>
		<mx:FileSystemDataGrid id="dataGrid"
							   width="100%" height="100%"
							   directory="{new File('c:\\')}"/>
	</mx:HDividedBox>
</s:Window>

 

 

 

 

 

又搞到好晚。。明天还有一大堆报告要写。下班前交。纠结.

 

你可能感兴趣的:(Flex AIR)