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 ?

7 Comments so far

  1. [...] AS3: Where is my onReleaseOutside. [...]

  2. [...] AS3: Where is my onReleaseOutside, code zen. [...]

  3. Luis Filip Paço on March 4th, 2008

    Hi,
    And here can we find your implementation?
    Thanks.

  4. arpit on March 5th, 2008

    @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.

  5. Neil on July 30th, 2008

    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.

  6. arpit on July 30th, 2008

    @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.

  7. Germo on July 13th, 2009

    Thanks this solve. So simple, so useful.
    I meet the problem today.

Leave a reply