Introducing the ApplicationUtil class
Yesterday, during my weekly football “service”, I spent a few minutes starting the ApplicationUtil class. So far, it consists of only two methods, getVersion and closeOpenWindows. The first accesses the application descriptor and returns the application’s version. closeOpenWindows is a necessity I learned in the Apollo days from Christian Cantrell. I had issues with my first AIR app, DestroyFlickr, where it wouldn’t quit, even if all of the visible windows were closed. I commonly use window visibility to show/hide utility windows, so the invisible ones were hanging around, keeping the app open. This method runs a quick loop to close all open windows, visible or not. It also includes an andQuit argument that, when true, sets autoExit to true, which quits the app upon close of the windows. Here’s some unnecessary example code to give this post more character:
1 2 3 4 5 6 7 8 9 10 | var version:String = ApplicationUtil.getVersion(); trace(version); // v1 trace(NativeApplication.nativeApplication.openedWindows.length); // 3 ApplicationUtil.closeOpenWindows(); trace(NativeApplication.nativeApplication.openedWindows.length); // 0 // suppose three windows are open again ApplicationUtil.closeOpenWindows(true); // closes windows and quits before trace is called trace(NativeApplication.nativeApplication.openedWindows.length); |
You (or anyone) might be interested in my App utility class, found in the adobe-air-util Google Code project.
I hope this helps.
@Quentin — You have a good set of methods there. Keep up the great work!