views:

381

answers:

1

Hello,

I'm sure this must be a common question, but I haven't found an answer elsewhere.

I've got a Flash object embedded in a long webpage. I listen for the MOUSE_WHEEL event in Flash, and scroll my Flash content accordingly. However, when I scroll over the Flash object, the webpage also scrolls.

Is there any way to prevent this behaviour, i.e. lock the webpage's scrolling position when the Flash object has focus? I'd prefer not to have to use JavaScript.

+2  A: 

I don not think this is possible without JavaScript.

You would need to communicate from the Flash movie to the browser using ExternalInterface whenever the Flash movie changes focus.

Then, have a JavaScript function on the page trap and eat the mousewheel event:

if (window.addEventListener)
    /** DOMMouseScroll is for mozilla. */
    window.addEventListener('DOMMouseScroll', handleWheelEvent, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = handleWheelEvent;

function handleWheelEvent(e){
    e.preventDefault();
}
81bronco
Thanks, I didn't know you could cancel events in JavaScript
Cameron