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

转: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

你可能感兴趣的:(xml,Blog,AIR)