AS3: Where is my onReleaseOutside

This is the most annoying point I have reached with AS3 yet. AS3 does not have an onReleaseOutside event, something I really needed for a menu to hide if the user clicked away from it. One implementation that I did find here involves a deeper understanding of the event bubbling mechanism. My own implementation is simpler and I just listen to a global application mouse click and see if my menu is down or not. However i do imagine lack of this event would make many developers go nuts. What sucks even more is that event isnt even available on the Flex framework. Maybe something we can ask for in 2.1 ?

Author: Arpit Mathur

Arpit Mathur is a Principal Software Engineer at Comcast Labs where he is currently working on Virtual and Augmented Reality as well as investigating Blockchains and the decentralized internet.

7 thoughts on “AS3: Where is my onReleaseOutside”

  1. @Luis:
    The code is as simple as:
    my_sprite.stage.addEventListener(MouseEvent.UP, doOnReleaseOutside)
    Actually this is an old post and I recommend the one linked to the tip of the day post by sinocular.


  2. arpit

    my_sprite.stage.addEventListener(MouseEvent.UP, doOnReleaseOutside)

    this will be invoked if the user does a click anywhere on the stage. What is to stop the user clicking on something that does not take a click, like a logo for example, that would fire your function.


  3. @Neil
    As long as the element clicked on does not capture the event, the mouse up event will bubble to the stage and the eventListener will be executed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s