Try this if you want to close all of the Windows that have been created in an AIR app.
NativeApplication.nativeApplication.addEventListener( Event.EXITING, exitApp );
private function exitApp( e:Event ):void {
e.preventDefault();
for ( var i:int = NativeApplication.nativeApplication.openedWindows.length - 1; i >= 0; --i ) {
NativeWindow( NativeApplication.nativeApplication.openedWindows[i] ).close();
}
}
If you create an AIR app that opens chromeless Windows that don’t have any close buttons then you’re kind of screwed if you close the main window and just leave the spawned windows hanging. You won’t be able to publish again until all the windows are closed. At least that’s how it works on WinXP.
I have noticed that when testing an AIR app from Flex Builder it shows up as adl.exe in the Windows Task Manager. So ending that process will close your app, and any windows it spawned.





Excelente… tanks…
Hi Dan,
Can you tell me the way please how can i proof opened windows ??
I add an Window but i want to proof ist this window on the desktopo or not.
Actaully i set an Boolena for this but i think the windows can tell me this without this param from me but i dont no the parameter .
window.closed doesnt wor k for me always tell … null object reference ..
thx for help Pascal
@DocMabuse, Offhand I’m not sure how to do that. But I’m going to be working on an AIR app later this week. If I run across the solution I’ll email you.
private function onMinimized(e:NativeWindowDisplayStateEvent):void{
e.preventDefault();
trace("target was Minimized or not :" + e.target);
if(e.beforeDisplayState == "normal"){
trayIcon(NativeApplication.supportsSystemTrayIcon, NativeApplication.supportsDockIcon);
}
}
try this beforeDisplayState and afterDisplayState is the Magic :)
dont forget add tehe listener
look like this
listview.addEventListener( NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, onMinimized );
@DocMabuse, nice work. This should be a post on your blog – hint, hint. :)
so onChange maybe is better nam for method
I have an Air app with two windows, i want add an closing event to close all windows when a window closed.
window1.stage.nativeWindow.addEventListener( Event.CLOSING, exitApp );
private function exitApp( e:Event ):void {
e.preventDefault();
window2.close();
}
but error return:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@7f09dd1 to flash.events.NativeWindowDisplayStateEvent
@Nim I’m not sure where ‘window2′ entered the picture. Why don’t you just use the code example in the post here. That works.