SimpleMouseEvents (onReleaseOutside, onDragOut,…)
May 21st, 2007
Some of the most confronted issues in AS3 are the missing mouse events as onReleaseOutside, onDragOut, onDragOver and so on. I saw that question over all boards. While coding the TR909, I had the same problem and I tried to figure out a common solution. I wrote a wrapper class, which adds itself as a listener to the passed target object. It takes care of the fact, that the stage can be null (required for releaseOutside) and the stage focus. It also provides (if necessary) the trackAsMenu mode to receive onDragOut, onDragOver, if the target itself doesn't have the focus.
source code + sample application
Filed under: actionscript
14 Responses to “SimpleMouseEvents (onReleaseOutside, onDragOut,…)”
-
Andrew Says:
May 24th, 2007 at 10:14 pmI’m having trouble getting the RELEASE functionality working. Everything seems to work fine. I copied the code over directly from the Main.as that came with the zip.
Any suggestions/bug comments?
-
André Michelle Says:
May 25th, 2007 at 8:04 amWhat is your target? Make sure that the target property buttonMode must have the value ‘true’.
-
zguillez Says:
June 1st, 2007 at 11:48 amWow! great work, thanks ;)
-
swallow.sz Says:
June 21st, 2007 at 3:29 amthanks, this is what I need.
-
Rafeo Says:
July 9th, 2007 at 5:24 pmSo many thanks!! Just what I need too!!
-
Daniel Says:
October 26th, 2007 at 4:12 pmWonderful :)
-
Daniel Says:
December 19th, 2007 at 2:09 pmHi Andre,
when using cs3 components the RELEASE Event seems to fail. I could nail it down to a focus problem. AFAIK the components use their own focus-management, which seems to interfere the ‘target.stage.focus’ property.
if( target.stage.focus == target )
// is never fired when using components
dispatch(SimpleMouseEvent.RELEASE);without this condition the event is fired normally…but that can’t be the solution ;)
-
Rasso Says:
February 26th, 2008 at 6:53 pmHey André, first of all thanks for this nice class! I used it before here and everything worked fine (in this case, I wrote everything in one Main-Class).
Now I’m trying to use it again in a sub-Class, but my Button (on the stage) doesn’t respond, even if it obviously gets registered (the hand-cursor appears)…
I would be very grateful for your help! -
cathelper Says:
April 1st, 2008 at 12:03 amHi Andre, i’d like to thank you for this wonderful piece of work. It helped us a lot.
One question, i’m having the same problem with components as Daniel posted on December 19th.
You can take a look at the problem in
http://www.malldelsol.mash.com.ec
If you click on ‘eventos’ the buttons for scrolling use the events class and work.
But…if you click on ‘locales comerciales’ before entering ‘eventos’ then the buttons fail to get the RELEASE event.
I isolated the problem on the presence of flash components ‘Combo’ and/or ‘List’. Even tough i exit ‘locales comerciales’ it seems that the problem still exists.
Any comment on this would be very appreciated.
Thanks for all the support.
-
Jed Says:
November 18th, 2008 at 6:21 pmYep, running into the same problem with the CS3 components as the above posters. Looks like they clobber the stage.focus property by continually setting it to null. The problem only exhibits itself once a component has been added to the display list.
-
Jed Says:
November 18th, 2008 at 6:25 pmSorry, got that wrong: the CS3 components continually set stage.focus to themselves, rather than null.
-
Jed Says:
November 18th, 2008 at 6:39 pmSolution for CS3 components issue: listen to the traditional MouseEvent.MOUSE_UP instead of the missing SimpleMouseEvent.RELEASE, while continuing to leverage Andre’s SimpleMouseEvent.RELEASE_OUTSIDE as per normal … right?
-
xtyler AS3 Button Behavior Made Easy Says:
January 30th, 2009 at 3:18 am[...] implemented 3 new events: stateUp, stateOver and stateDown. Andre Michelle wrote on this same subject almost 2 years ago and posted a similar solution. I took the opportunity to review his and it works [...]
-
OnReleaseOutside in AS3 Says:
March 7th, 2009 at 5:43 pm[...] you don’t have to write that becouse Andre Michelle did it already, thanks for him! His SimpleMouseEvents is a very useful and easy-to-use class that can be handle onReleaseOutside, onDragOut and [...]

