flex day 3-html和window组件

本文介绍了如何使用Flex MXML创建一个包含窗口组件、按钮、HTML内容显示和文件系统树视图的应用。通过新建窗口、事件监听等操作实现了窗口的隐藏与显示,并详细展示了如何基于mx.core.Window创建自定义组件和如何在组件中集成文件系统树视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

 

 

 

 

 

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

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值