Skip to main content
Known Participant
September 12, 2011
Question

Limiting MouseWheel activation area on a page (AS3)

  • September 12, 2011
  • 1 reply
  • 1006 views

Hi,

I am not sure if I have put a good title for this question, but I have tried to makeit as clear as I can.

I have one page with three different scroll texts. I have programmed to scroll them by MouseWheel. They are on three diffrent parts of the page and there is no overlap. Now, the problem is when I scroll down or up one of them, the other ones move as well. How can I disable the other two ones when I am on one of the scroll texts?

The code that I have used for MouseWheel event:

function MouseWheelScroller(event:MouseEvent):void{

     if((event.delta < 0 && work_scroller.y > 0)||

     (event.delta > 0 && work_scroller.y < 153 - work_scroller.height)){

      work_scroller.y = work_scroller.y + (event.delta * 2);

     }

}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,MouseWheelScroller);

May be if I make each scroll text as an external SWF, the problem will be solved. But I prefer not to do it.

Has anyone any solution for my problem?

Thank you in advance.

This topic has been closed for replies.

1 reply

markerline
Inspiring
September 12, 2011

Why not add your event listeners to each of the text areas (or create an invisible MovieClip

over each individual text area and use that for the event listener)?  Right now you have it addressing the stage which is why the entire stage listens to your Scrolls.

markerline
Inspiring
September 12, 2011

You might also consider using a MOUSE_OVER event in conjunction with your current listeners to check whether the mouse is over a specific text field.

Known Participant
September 12, 2011

Hi,

Thanks for your tips.

1. Each scroll text is already programmed in a separated movie clip and the MouseWheel event for each scroll text is program in its movie clip, but the problem is occured.

2. About your second tip: I have not worked with MOUSE_OVER event. I look for tutorials. If you have any example, I will be thankful f you send it.

3. Do you have any opinion about each scroll text as an external SWF? Can the problem be solved with such a trick?

Thanks in advance!