/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// *** inside javascript ** function handleWheel(event) { var app = document.getElementById('flashSite'); var delta = 0; if (!event) event = window.event; if (event.wheelDelta) { delta = -(event.wheelDelta/60); } else if (event.detail) { delta = event.detail; } var o = { x: event.screenX, y: event.screenY, delta: delta, ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey }; if (app && typeof(app.handleWheel) == 'function') app.handleWheel(o); } // on page onload if(!(document.attachEvent)) { window.addEventListener("DOMMouseScroll", handleWheel, false); window.addEventListener('mousewheel', handleWheel, false); document.addEventListener('mousewheel', handleWheel, false); } // *** inside flash *** if(ExternalInterface.available){ ExternalInterface.addCallback("handleWheel", handleWheel); } // method that will be accessed from dispatched javascript events public function handleWheel(event:Object): void { var mEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_WHEEL, true, false, event.x, event.y, this, event.ctrlKey, event.altKey, event.shiftKey, false, -Number(event.delta)); this.dispatchEvent(mEvent); // where "this" is the documentClass. Can be "stage" too }