Note that there are some explanatory texts on larger screens.

plurals
  1. POEasiest implementation of onReleaseOutside in AS3?
    text
    copied!<p>I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when really it's up. </p> <p>According to the <a href="http://livedocs.adobe.com/flex/2/langref/migration.html" rel="nofollow noreferrer">AS2 to AS3 Migration Guide</a>, I'm supposed to use <code>flash.display.InteractiveObject.setCapture()</code> for this, however it does not exist as far as I can tell. I guess this document is out of date or incorrect. I've found a few posts on the web about how to duplicate this functionality, but they either have their own problems:</p> <ul> <li><a href="http://www.arpitonline.com/blog/?p=33" rel="nofollow noreferrer">This one</a> triggers onReleaseOutside even if there was no corresponding onPress event. </li> <li><a href="http://www.kirupa.com/forum/showpost.php?p=1948182&amp;postcount=204" rel="nofollow noreferrer">This one</a> seems very inefficient, you'll add and remove an event listener every time the mouse is clicked anywhere inside your app.</li> </ul> <p>There has to be an easier way, don't tell me Adobe forgot about this when rewriting Actionscript?</p> <p>Example AS2 code:</p> <pre><code>// Assume myMC is a simple square or something on the stage myMC.onPress = function() { this._rotation = 45; } myMC.onRelease = myMC.onReleaseOutside = function() { this._rotation = 0; } </code></pre> <p>Without the onReleaseOutside handler, if you pressed down on the squre, dragged your mouse outside of it, and released the mouse, then the square would not un-rotate, and appear to be stuck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload