鼠标滚轮滚动 Flash 内容
我试图在离开/输入 Flash 内容后更改鼠标滚轮的事件。
- 在 Flash 上 - 我想
- 在 Web 上滚动 Flash 轮播 - 我想滚动 Web 内容
我的问题是:
不同的浏览器为 Flash 元素提供不同的“焦点”,因此在事件中无法正确触发:Event.MOUSE_LEAVE
,MouseEvent.MOUSE_OVER
。我为 MOUSE_OVER
和 MOUSE_LEAVE
触发了 JS,但这似乎不起作用。
另外,mouseWheel 属于浏览器,而不是 flash 对象。
Firefox 4.x/5.0 - 无需点击即可正确触发它们 Chrome 12.0.742.112 - 它在授予“焦点”或单击 flash 对象后触发,如 IE 9.0.1
JS 代码:
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(){ stopWheel(); } /* 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);
}
}
有什么我可以更改的吗?
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(){ stopWheel(); } /* 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Flash中你可以监听鼠标滚轮事件。如果你确实有一个事件监听器,那么它甚至会阻止传播到 html 页面。当你在闪光灯之外时,轮子事件正在做它应该做的事情(滚动网站)
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)