Skip to main content
Participant
June 17, 2006
Question

Mouse.listener

  • June 17, 2006
  • 3 replies
  • 278 views
Is there a way to use the Mouse.listener to detect what the name of the item is that you clicked on. I have instances where the button or movieclip functions are not correctly picking up the release or mouseUp events but the Mouse.listener is shwoing me it is not missing a click, so I want to use the listener in some areas as the click detection driver, but need to know what the user clicked on.
This topic has been closed for replies.

3 replies

Inspiring
June 19, 2006
cpbittner,

> The code for the button is:
> next.onRelease = function() {
> goNextPage();
> };

I can only assume that goNextPage() is a custom function, because it
doesn't appear in the ActionScript Language Reference. It may be that on
examples like this, you're assuming the onRelease event doesn't fire because
nothing happens -- but maybe in actuality, it could be that goNextPage()
doesn't do anything.

The Button.onRelease event always fires. Prove it to yourself by adding
a trace() function to that same button:

next.onRelease = function() {
trace("supposed to trigger goNextPage()");
goNextPage();
};

You'll see the the quoted string in your Output panel.

In fact, you can use trace() to output the button's instance name, which
is what you were asking for earlier:

next.onRelease = function() {
trace(this._name);
goNextPage();
};

The "Button class" entry of the ActionScript 2.0 Language Reference will
show you everything a button offers. As with all class entries, you'll find
one or more of the following three categories: properties (characteristics
the object has), methods (things the object can do) and events (things the
object can react to).

> Turns out the button is thinking the user has rolled off
> the button when the user is clicking the button even if
> the user stays put and does not move the mouse - but
> only after the user has clicked on an asfucntion hyperlink
> on a page that contains a hyperlink.

Sounds like there's a lot going on under the hood on this one. I don't
envy you the headache. ;) I really think tracing the Button._name property
on your event handlers is the best/easiest way to troubleshoot this one.


David
stiller (at) quip (dot) net
Dev essays: http://www.quip.net/blog/
"Luck is the residue of good design."


cpbittnerAuthor
Participant
June 20, 2006
Everything still points to the asFunction call causing an issue with the buttons. I use trace to debug everything and that is how I saw that the button appeared to be getting temporarily disabled as the onRelease wasn't getting fired (no trace reply). Thanks for your feedback anyway.
cpbittnerAuthor
Participant
June 19, 2006
The code for the button is:
next.onRelease = function() {
goNextPage();
};

Unfortunately, I am dealing with a training shell that has a ton of legacy code, with no budget/time/permission to start yanking code to clean it up. (There is no money to clean up the shell - but yet I have put numerious hours into debugging misc behaviors - go figure) I wanted to use the mouse listener for debugging, but found a different way to test. Turns out the button is thinking the user has rolled off the button when the user is clicking the button even if the user stays put and does not move the mouse - but only after the user has clicked on an asfucntion hyperlink on a page that contains a hyperlink. So it appears the asfunction command is affecting something. I've got to narrow down the behavior more then determine how to repost the issue.
Inspiring
June 17, 2006
cpbittner,

> Is there a way to use the Mouse.listener to detect
> what the name of the item is that you clicked on.

Not really. You could use something like MovieClip.hitTest() to cycle
through all the available movie clips until you find the one under the
mouse, but that could potentially be pretty tedious -- and, in any case, is
unecessary.

> I have instances where the button or movieclip
> functions are not correctly picking up the release
> or mouseUp events but the Mouse.listener is
> shwoing me it is not missing a click,

Aha! Well, there's your issue, then. :) Let's see example code for a
movie clip whose events aren't being handled. Let's fix your problem at the
source, rather than evading it.


David
stiller (at) quip (dot) net
Dev essays: http://www.quip.net/blog/
"Luck is the residue of good design."