A fun way to open a native window in AIR with MATE

本文介绍了一种有趣的使用MATE在Adobe AIR应用中打开原生窗口的方法。作者通过实验摆脱传统管理器模式,在点击事件中利用PropertySetter显示窗口,提供了一段具体的实现代码。

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

转:http://blog.petermolgaard.com/2009/07/18/a-fun-way-to-open-a-native-window-in-air-with-mate/

Sometimes when coding it happens that you stumble on something which just strikes you as funny (sometimes for apparently no reason whatsoever).
One such experience happened today when I was coding an AIR client with MATE and I had to open a new NativeWindow.
It should be noted that I for this implementation am experimenting with ridding myself of using Managers (no other motivation than curiosity about will come out in terms of code design and architecture).

Well, the thing that amused me was to use a PropertySetter. This is due to the fact that you have to set the “visible” property in order to actually show the window. However, you also have to pass an object of the type “NativeWindowInitOptions” to the constructor.

The code eventually can be written like this…
view source
print?
01 <?xml version="1.0" encoding="utf-8"?>
02 <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/halo" xmlns:local="*">
03
04 <s:Button label="Click Me" />
05
06 <fx:Declarations>
07 <local:GlobalEventMap2 />
08 </fx:Declarations>
09
10 </s:WindowedApplication>
view source
print?
01 <?xml version="1.0" encoding="utf-8"?>
02 <mate:EventMap xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:mate="http://mate.asfusion.com/">
03
04 <fx:Declarations>
05
06 <mate:EventHandlers type="{ MouseEvent.CLICK }">
07 <mate:PropertySetter
08 generator="{ NativeWindow }"
09 constructorArguments="{ [ new NativeWindowInitOptions() ] }"
10 cache="none"
11 targetKey="visible"
12 source="{ true }" />
13 </mate:EventHandlers>
14
15 </fx:Declarations>
16
17 </mate:EventMap>A fun way to open a native window in AIR with MATE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值