chrome、ff下flash的mousewheel事件失效(wmode=transparent)
目前想到的解决方法,监听页面的鼠标中轮事件,然后回传给flash
function addEvent(elem, type, handler) {
type = type.replace(/^on/, '');
if (elem.attachEvent) {
elem.attachEvent('on' + type, handler);
} else if (elem.addEventListener) {
elem.addEventListener(type, handler, false);
}
}
//支持非IE、firefox浏览器
!(function() {
var swfEl = getEl('God_main');
var ua = navigator.userAgent.toLowerCase();
if (swfEl.addEventListener && !/(ie|opera)/.test(ua)) {
var eventType = /firefox/.test(ua) ? 'DOMMouseScroll' : 'mousewheel';
addEvent(swfEl, eventType, handleWheel);
}
})();
function handleWheel(event) {
var delta = /firefox/.test(navigator.userAgent.toLowerCase()) ? -event.detail : event.wheelDelta/40;
var swfEl = getEl('swfId');
swfEl.mouseWheel(delta);
}
AS中添加代码:
ExternalInterface.addCallback('mouseWheel', mouseWheelCallback);