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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Handling ev<strong>en</strong>ts<br />

/**<br />

* Creates and returns a copy of the curr<strong>en</strong>t instance.<br />

* @return A copy of the curr<strong>en</strong>t instance.<br />

*/<br />

public override function clone():Ev<strong>en</strong>t<br />

{<br />

return new AlarmEv<strong>en</strong>t(message);<br />

}<br />

/**<br />

* Returns a String containing all the properties of the curr<strong>en</strong>t<br />

* instance.<br />

* @return A string repres<strong>en</strong>tation of the curr<strong>en</strong>t instance.<br />

*/<br />

public override function toString():String<br />

{<br />

return formatToString("AlarmEv<strong>en</strong>t", "type", "bubbles", "cancelable", "ev<strong>en</strong>tPhase",<br />

"message");<br />

}<br />

The overridd<strong>en</strong> clone() method needs to return a new instance of the custom Ev<strong>en</strong>t subclass, with all the custom<br />

properties set to match the curr<strong>en</strong>t instance. In the overridd<strong>en</strong> toString() method, the utility method<br />

formatToString() (inherited from Ev<strong>en</strong>t) is used to provide a string with the name of the custom type, as well as the<br />

names and values of all its properties.<br />

Last updated 6/6/2012<br />

146

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

Saved successfully!

Ooh no, something went wrong!