I'm trying to change event for mousewheel after leaving / entering flash content.
- on flash - I want to scroll flash carousel
- on web - I want to scroll web content
My problem is:
Different browsers give different "focus" for flash element and therefore not properly triggered in events: Event.MOUSE_LEAVE
, MouseEvent.MOUSE_OVER
. I have JS triggered for MOUSE_OVER
and MOUSE_LEAVE
but this seems not to work.
Also mouseWheel is attributed to the browser, not a flash object.
Firefox 4.x/5.0 - fires them properly, without clicking Chrome 12.0.742.112 - it fires after the grant of "focus" or click on the flash object, like IE 9.0.1
JS code:
function stopWheel(e){
if(!e){ e = window.event; } /* IE7, IE8, Chrome, Safari */
if(e.preventDefault) { e.preventDefault(); } /* Chrome, Safari, Firefox */
e.returnValue = false; /* IE7, IE8 */
}
function player_enter(){
document.onmousewheel = function(){ s开发者_如何学编程topWheel(); } /* IE7, IE8 */
if(document.addEventListener){ /* Chrome, Safari, Firefox */
document.addEventListener('DOMMouseScroll', stopWheel, false);
}
}
function player_leave(){
document.onmousewheel = null; /* IE7, IE8 */
if(document.addEventListener){ /* Chrome, Safari, Firefox */
document.removeEventListener('DOMMouseScroll', stopWheel, false);
}
}
Is there anything I could change?
in flash you can listen for the mouse wheel event. and if you do have an event listener there, then it will stop the wheel even from propagating to the html page. and when you are outside the flash, the wheel event is doing what it should (scrolling the website)
addEventListener(MouseEvent.MOUSE_WHEEL, handleMouseWheel);
精彩评论