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 />

}<br />

}<br />

}<br />

var s:Sprite = new Sprite();<br />

s.graphics.beginFill(color);<br />

s.graphics.drawRect(0, 0, size, size);<br />

s.graphics.<strong>en</strong>dFill();<br />

s.x = x;<br />

s.y = y;<br />

this.addChild(s);<br />

return s;<br />

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

{<br />

this.stage.nativeWindow.startResize(NativeWindowResize.BOTTOM_RIGHT);<br />

}<br />

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

{<br />

this.stage.nativeWindow.startMove();<br />

}<br />

List<strong>en</strong>ing for window ev<strong>en</strong>ts<br />

Adobe AIR 1.0 and later<br />

To list<strong>en</strong> for the ev<strong>en</strong>ts dispatched by a window, register a list<strong>en</strong>er with the window instance. For example, to list<strong>en</strong> for<br />

the closing ev<strong>en</strong>t, register a list<strong>en</strong>er with the window as follows:<br />

myWindow.addEv<strong>en</strong>tList<strong>en</strong>er(Ev<strong>en</strong>t.CLOSING, onClosingEv<strong>en</strong>t);<br />

Wh<strong>en</strong> an ev<strong>en</strong>t is dispatched, the target property refer<strong>en</strong>ces the window s<strong>en</strong>ding the ev<strong>en</strong>t.<br />

Most window ev<strong>en</strong>ts have two related messages. The first message signals that a window change is immin<strong>en</strong>t (and can<br />

be canceled), while the second message signals that the change has occurred. For example, wh<strong>en</strong> a user clicks the close<br />

button of a window, the closing ev<strong>en</strong>t message is dispatched. If no list<strong>en</strong>ers cancel the ev<strong>en</strong>t, the window closes and<br />

the close ev<strong>en</strong>t is dispatched to any list<strong>en</strong>ers.<br />

Typically, the warning ev<strong>en</strong>ts, such as closing, are only dispatched wh<strong>en</strong> system chrome has be<strong>en</strong> used to trigger an<br />

ev<strong>en</strong>t. Calling the window close() method, for example, does not automatically dispatch the closing ev<strong>en</strong>t—only<br />

the close ev<strong>en</strong>t is dispatched. You can, however, construct a closing ev<strong>en</strong>t object and dispatch it using the window<br />

dispatchEv<strong>en</strong>t() method.<br />

The window ev<strong>en</strong>ts that dispatch an Ev<strong>en</strong>t object are:<br />

Ev<strong>en</strong>t Description<br />

activate Dispatched wh<strong>en</strong> the window receives focus.<br />

deactivate Dispatched wh<strong>en</strong> the window loses focus<br />

closing Dispatched wh<strong>en</strong> the window is about to close. This only occurs automatically wh<strong>en</strong> the system chrome close<br />

button is pressed or, on Mac OS X, wh<strong>en</strong> the Quit command is invoked.<br />

close Dispatched wh<strong>en</strong> the window has closed.<br />

Last updated 6/6/2012<br />

914

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

Saved successfully!

Ooh no, something went wrong!