Skip to main content
Participant
June 5, 2007
Question

DOUBLE_CLICK help

  • June 5, 2007
  • 6 replies
  • 389 views
I can't understand why this code doesn't work, please help.


button1.addEventListener (MouseEvent.DOUBLE_CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
var url:String = " http://www.hotmail.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request);
} catch (e:Error) {
trace("Error occurred!");
}
}

However, CLICK works fine.

Thanks,

Yin
This topic has been closed for replies.

6 replies

Inspiring
July 30, 2007
Woops. I mean to add:

And if you comment out the line btn.doubleClickEnabled = true; (or
change it to false), the CLICK event handler outputs its line twice in
response to a quick succession of clicks.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Inspiring
July 30, 2007
Patrick,

> Setting the doubleClickEnabled flag works fine, but
> when it's set to false, this same code simply doesn't work.
> It doesn't fire the function off twice in quick succession or
> anything, it simply does nothing. Does anyone know why?

The only explanation I would venture is that the event handler is
specifically listening for the MouseEvent.DOUBLE_CLICK event. By
definition, that isn't a succession of single clicks, it's a double click.

If you write an event handler for MouseEvent.CLICK, you'll see it fire
for single clicks, but not double clicks, which may clarify the distinction
(admittedly a subtle one). For example, this snippet:

btn.doubleClickEnabled = true;
btn.addEventListener(
MouseEvent.CLICK,
function(e:MouseEvent):void {
trace("single click")
}
);
btn.addEventListener(
MouseEvent.DOUBLE_CLICK,
function(e:MouseEvent):void {
trace("double click")
}
);

... outputs the following in a double-click situation:

single click
double click


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Inspiring
July 30, 2007
Hi everyone,

According to the documentation on this function:

"If the target InteractiveObject does not have its doubleClickEnabled
flag set to true it receives two click events."

The code I have is:

public function onDoubleCick(eventObj:MouseEvent):void {
trace ('double click!');
}

//in constructort
this.addEventListener(MouseEvent.DOUBLE_CLICK,this.onDoubleClick);

Setting the doubleClickEnabled flag works fine, but when it's set to
false, this same code simply doesn't work. It doesn't fire the function
off twice in quick succession or anything, it simply does nothing. Does
anyone know why?

Thanks,
Partick



kglad wrote:
> www.senocular.com has lots of helpful information.

--
http://www.baynewmedia.com
Faster, easier, better...ActionScript development taken to new heights.
Download the BNMAPI today. You'll wonder how you ever did without it!
Available for ActionScript 2.0/3.0.
kglad
Community Expert
Community Expert
June 6, 2007
www.senocular.com has lots of helpful information.
kglad
Community Expert
Community Expert
June 5, 2007
use button1.doubleClickEnabled=true;
theyinheAuthor
Participant
June 6, 2007
Thanks so much for your help! Are there any good resources for Actionscript 3? Unfortunately, none of the books on the subject are going to be out until a few months from now...
Inspiring
June 5, 2007
theyinhe,

> I can't understand why this code doesn't work, please help.
>
>
> button1.addEventListener (MouseEvent.DOUBLE_CLICK, clickHandler);
// snipped code

> However, CLICK works fine.

Did you set the button's doubleClickEnabled property to true?


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."