ContextWindow
| By Rich Tretola | February 13, 2008 | |
| 1,942 views |
Looking for an easy way to add window controls as a context menu to your AIR windows? Try my new ContextWindow class.

So this is not rocket science by any means, it is just a class that extends mx.core.Window and creates a NativeMenu within the constructor and assigns it to the contextMenu property.
This example creates an instance of a ContextWindow:
1 2 3 4 5 6 | private function createContextWindow():void{ var w:ContextWindow = new ContextWindow(); w.width=300; w.height=200; w.open(); } |
The code below shows how to subclass ContextWindow as an MXML object:
1 2 3 4 5 6 7 8 9 10 | <?xml version="1.0" encoding="utf-8"?> <contextWindow xmlns="com.everythingflex.air.components.*" layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="150"> <mx:Label text="This is a ContextWindow" horizontalCenter="0" verticalCenter="0" /> </contextWindow> |
Here is the full sample code for this demonstration of the AlertWindow component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import com.everythingflex.air.components.ContextWindow; private function createContextWindow():void{ var w:ContextWindow = new ContextWindow(); w.width=300; w.height=200; w.open(); } private function openContextWindow():void{ var w:Win1 = new Win1(); w.open(); } ]]> </mx:Script> <mx:Button click="createContextWindow()" label="Create ContextWindow" x="150.5" y="147" width="225"/> <mx:Button click="openContextWindow()" label="Open ContextWindow Component" x="150.5" y="177" width="225"/> </mx:WindowedApplication> |







