13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with AIR native windows<br />

public function onCloseCommand(ev<strong>en</strong>t:MouseEv<strong>en</strong>t):void{<br />

var closingEv<strong>en</strong>t:Ev<strong>en</strong>t = new Ev<strong>en</strong>t(Ev<strong>en</strong>t.CLOSING,true,true);<br />

dispatchEv<strong>en</strong>t(closing);<br />

if(!closingEv<strong>en</strong>t.isDefaultPrev<strong>en</strong>ted()){<br />

win.close();<br />

}<br />

}<br />

The dispatchEv<strong>en</strong>t() method returns false if the ev<strong>en</strong>t prev<strong>en</strong>tDefault() method is called by a list<strong>en</strong>er.<br />

However, it can also return false for other reasons, so it is better to explicitly use the isDefaultPrev<strong>en</strong>ted()<br />

method to test whether the change should be canceled.<br />

Maximizing, minimizing, and restoring a window<br />

Adobe AIR 1.0 and later<br />

To maximize the window, use the NativeWindow maximize() method.<br />

myWindow.maximize();<br />

To minimize the window, use the NativeWindow minimize() method.<br />

myWindow.minimize();<br />

To restore the window (that is, return it to the size that it was before it was either minimized or maximized), use the<br />

NativeWindow restore() method.<br />

myWindow.restore();<br />

A window that has an owner is minimized and restored wh<strong>en</strong> the owning window is minimized or restored. No ev<strong>en</strong>ts<br />

are dispatched by the owned window wh<strong>en</strong> it is minimized because its owner is minimized.<br />

Note: The behavior that results from maximizing an AIR window is differ<strong>en</strong>t from the Mac OS X standard behavior.<br />

Rather than toggling betwe<strong>en</strong> an application-defined “standard” size and the last size set by the user, AIR windows toggle<br />

betwe<strong>en</strong> the size last set by the application or user and the full usable area of the scre<strong>en</strong>.<br />

On the Linux operating system, differ<strong>en</strong>t window managers <strong>en</strong>force differ<strong>en</strong>t rules regarding setting the window<br />

display state:<br />

On some window managers, utility windows cannot be maximized.<br />

If a maximum size is set for the window, th<strong>en</strong> some windows do not allow a window to be maximized. Some other<br />

window managers set the display state to maximized, but do not resize the window. In either of these cases, no<br />

display state change ev<strong>en</strong>t is dispatched.<br />

Some window managers do not honor the window maximizable or minimizable settings.<br />

Note: On Linux, window properties are changed asynchronously. If you change the display state in one line of your<br />

program, and read the value in the next, the value read will still reflect the old setting. On all platforms, the<br />

NativeWindow object dispatches the displayStateChange ev<strong>en</strong>t wh<strong>en</strong> the display state changes. If you need to take<br />

some action based on the new state of the window, always do so in a displayStateChange ev<strong>en</strong>t handler. See “List<strong>en</strong>ing<br />

for window ev<strong>en</strong>ts” on page 914.<br />

Last updated 6/6/2012<br />

909

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!