• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Disable MouseEvents for certain objects.

New Here ,
Mar 23, 2009 Mar 23, 2009

Copy link to clipboard

Copied

I have a flash AS3 doc and some classes that I created. On one of the classes, it creats a sprite that may have a scroll bar, (which i also made - not the UIScrollBar component). This uses the MOUSE_DOWN event for scrolling.

On some other classes, there are some objects that use the MOUSE_OVER event.

The problem I have, is that if you click and hold the mouse button to begin scrolling, then move the cursor outside of this Movie Clip onto another with the MOUSE_OVER event, then that event will still fire. Also, if you MOUSE_UP and you are outside the Movie Clip (with the scrollbar) then the MOUSE_UP event does NOT fire, and the scrolling is "locked" on until you click inside that moive clip.

How can I prevent mouse events on objects from firing when the MOUSE_DOWN event is firing for scrolling? Also, how can I make it so the MOUSE_UP event will fire no matter where on the stage the mouse cursor is.

I can't seem to figure it out because the MOUSE_DOWN, MOUSE_UP and MOUSE_OVER for the different objects have the eventListeners created in diffferent classes.

thanks.
TOPICS
ActionScript

Views

954

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 23, 2009

Copy link to clipboard

Copied

Although the mousedown is on the scroller, the mousemove listener should be on the stage, otherwise you would have to keep the mouse within the scroller. You probably have already done that, but also make your mouseup listener be on the stage too.

If you want all other things with mouseover listeners to not react, then on your mousedown handler turn off all of the mouseover listeners, and then in your mouseup handler turn them back on again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2009 Mar 24, 2009

Copy link to clipboard

Copied

Thank you for the reply.

That is kind of the direction I am heading, but I am confused where to put the code. Right now, the MOUSE_DOWN and MOUSE_UP listeners are both specified in the Class that has the scroller. The MOUSE_OVER listener is in the class for the the object that has the mouse over action.

So i've got 2 classes that I've made, ClassA, ClassB.

If I add a MOUSE_UP listener on the stage, how can I turn off the scrolling which is in ClassA? Likewise, if I add a MOUSE_DOWN listener on the stage, how can I turn off the MOUSE_OVER event that is in ClassB?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 24, 2009 Mar 24, 2009

Copy link to clipboard

Copied

LATEST
One way might be to dispatch an event. When you drag the scroller you would stage.dispatchEvent(new Event("scrolling")), and your other classes would have added an eventlistener to listen out for "scrolling", and would disable their mouseover function. When you're done you could do a dispatchEvent(new Event("stopscrolling")), and everyone listening for that would re-enable themselves.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines