« Create your first Apollo Window | Main | HTML Control »
Windowing with Apollo – full source code
By Rich Tretola | March 19, 2007
1,920 views

Windowing in Apollo is a very simple task.
The Windowing sample will demonstrate this by allowing you to set the preferences
of the new window by setting NativeWindow and NativeWindowInitOptions properties,
and then manage the windows by tracking them within a custom Array.
Creating a new window is as simple as this:
1
var newWindow:NativeWindow = new NativeWindow(true,new NativeWindowInitOptions());
The function that created the new windows in the Windowing sample looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private function createNewWindow():void{
// create initOptions
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
initOptions.appearsInWindowMenu = true;
initOptions.hasMenu = true;
initOptions.resizable = winResizable.selectedItem;
initOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
initOptions.transparent = winTransparent.selectedItem;
// create windows
var newWindow:NativeWindow = new NativeWindow( true, initOptions);
newWindow.title = winTitle.text;
newWindow.alwaysInFront = winAlwaysInFront.selectedItem;
newWindow.stage.addChild( new VBox() );
newWindow.width = winWidth.value;
newWindow.height = winHeight.value;
newWindow.x = winX.value;
newWindow.y = winY.value;
newWindow.addEventListener(flash.events.Event.CLOSE, closeEvent);
// add new window to ArrayCollection
windows.addItem(newWindow);
winControlsEnabled = true;
winY.value = windows.length * 50;
}
// create initOptions
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
initOptions.appearsInWindowMenu = true;
initOptions.hasMenu = true;
initOptions.resizable = winResizable.selectedItem;
initOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
initOptions.transparent = winTransparent.selectedItem;
// create windows
var newWindow:NativeWindow = new NativeWindow( true, initOptions);
newWindow.title = winTitle.text;
newWindow.alwaysInFront = winAlwaysInFront.selectedItem;
newWindow.stage.addChild( new VBox() );
newWindow.width = winWidth.value;
newWindow.height = winHeight.value;
newWindow.x = winX.value;
newWindow.y = winY.value;
newWindow.addEventListener(flash.events.Event.CLOSE, closeEvent);
// add new window to ArrayCollection
windows.addItem(newWindow);
winControlsEnabled = true;
winY.value = windows.length * 50;
}
Topics: Adobe AIR, Tutorials | 6 Comments »


![[image]](http://mowser.com/img?url=http%3A%2F%2Fassets.max.adobe.com%2Fimages%2FMAX09_D125x125.jpg)




March 19th, 2007 at 5:14 am
Well that the first Apollo app. I’ve tried so far. It work great for an alpha
I just had a windows alert and a memory read error at a moment but i couldn’t remake it.
Thanks for the source!
Reply to this comment
March 19th, 2007 at 5:25 am
Hi, nice app. You may reproduce error by trying to create transparent window. Windows XP/SP2
Reply to this comment
March 20th, 2007 at 3:32 am
[...] Başa bir uygulamayı Apollo ile pencere içine almak / Windowing [...]
March 28th, 2007 at 12:07 am
[...] (Hint: Follow Rich Tretola’s Windowing with Apollo tutorial.) [...]
April 4th, 2007 at 7:00 am
Hi, nice example, I don’t know if you have notice but the property nativeWindow.alwaysInFront doesn’t seems to do anything. Is this something that doesn’t work in the alpha version of apollo?
Reply to this comment
April 4th, 2007 at 7:06 am
Yes, I believe that is an alpha bug.
Reply to this comment