鼠标滚轮在swf中不起作用(浏览器镶边)

时间:2014-01-16 06:24:08

标签: javascript actionscript-3 google-chrome flash

所有其他浏览器都可以(请参阅 bottom mid)。我只能在Chrome(所有版本)中滚动列表。我使用这段代码:

package com.spikything.utils
{   import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.external.ExternalInterface;
    import fl.controls.*;

    public class MouseWheelTrap
    {   static private var _mouseWheelTrapped:Boolean;
        public static function setup(list:List):void
        {
            list.addEventListener(MouseEvent.MOUSE_OVER,function():void { allowBrowserScroll(false); });
            list.addEventListener(MouseEvent.MOUSE_OUT,function():void { allowBrowserScroll(true); });
        }
        private static function allowBrowserScroll(allow:Boolean):void
        {
            createMouseWheelTrap();
            if (ExternalInterface.available)
            {
                ExternalInterface.call("allowBrowserScroll",allow);
            }
        }
        private static function createMouseWheelTrap():void
        {
            if (_mouseWheelTrapped)
            {
                return;
            }
            _mouseWheelTrapped = true;
            if (ExternalInterface.available)
            {
                ExternalInterface.call("eval","var browserScrolling;function allowBrowserScroll(value){browserScrolling=value;}function handle(delta){if(!browserScrolling){return false;}return true;}function wheel(event){var delta=0;if(!event){event=window.event;}if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera){delta=-delta;}}else if(event.detail){delta=-event.detail/3;}if(delta){handle(delta);}if(!browserScrolling){if(event.preventDefault){event.preventDefault();}event.returnValue=false;}}if(window.addEventListener){window.addEventListener('DOMMouseScroll',wheel,false);}window.onmousewheel=document.onmousewheel=wheel;allowBrowserScroll(true);");
            }
        }
    }

}

在主要班级:

MouseWheelTrap.setup(this.previewScrollBox);
this.previewScrollBox.addEventListener(MouseEvent.MOUSE_WHEEL, this.showData);

这个javascript代码 - swfobject.js

1 个答案:

答案 0 :(得分:2)

关闭chrome://插件中的pepperflash解决了这个问题。这个愚蠢的玩家正在处理bug。或者您可以使用此BlastedMouseWheelBlock