« I'm "Burning" | ^ Main | AS3 XMLDataLoader »
Flash CS3 AS3: doubleClickEnabled "Gotcha"
Ok…I fought with this for wayyyyy too long, gave up, tried again tonight (for way too long), gave up, then had a thought. I went back to the help docs to re-read the instructions about using mouseEnabled as well as doubleClickEnabled…nothing new. Well, maybe something new. I noticed there was a related link to mouseChildren.
This was interesting and made me think. I noticed all stage items did not use the hand cursor. So, like all great developers, I used useHandCursor = true which works on certain parts of the items. I figured out it was because the children had mouse abilities too, which is a good default option in my opinion.
Ultimately, I remembered Ron Haberle’s code about using double click. His code (see below) was all code (just 1 sprite with a drawing) so there were no children with possible clicks.
import flash.display.Sprite;
import flash.events.MouseEvent;
var sp:Sprite = new Sprite();
sp.x = 100;
sp.y = 100;
sp.graphics.beginFill(0xe4e5e6);
sp.graphics.drawRect (0, 0, 100, 100);
sp.doubleClickEnabled = true;
sp.addEventListener(MouseEvent.DOUBLE_CLICK, handleClick);
addChild(sp);
function handleClick(evt:Event):void {
trace(“Double Click”);
}
This didn’t work for me. Let’s get back to present day/time from the previous paragraph (before “Ultimately, …”).
All I had to add was mouseChildren = false; to my constructor and the event was firing like clockwork. :-) Good thing too. I was about to mark off this item as a CS3 bug in the bug list. LOL. Hey, when all else fails…blame the software, another sign of a great developer. LMBO. ;-)
Posted by John C. Bland II on July 9, 2007 1:24 AM | Permalink
TrackBack
TrackBack URL for this entry:
http://mt.katapultmedia.com/mt-tb.cgi/288
Comments
Thanks for that - big help. One other thing to note is that when extending existing components this has to be called on updateDisplayList as it looks like it keeps getting reset (investigating why now!)
Posted by: Ian | July 9, 2007 11:29 PM
Good point. In my instance it is just a class extending Sprite so I didn’t have to worry about the updateDisplayList. Please post back when you have found out what is resetting it.
Posted by: John C. Bland II | July 10, 2007 9:54 AM



