屏蔽网页的滚轮事件

屏蔽网页的滚轮事件

博客分类: Flash/AS3

经常会在FLASH用到滚轮事件,可是网页中也会响应到, 加下面的代码, 调用就可以了

Java代码 复制代码  收藏代码
  1.     
  2. package    
  3. {   
  4.  import flash.display.Stage;   
  5.  import flash.external.ExternalInterface;   
  6.     
  7.  /**  
  8.   * 滚轮过滤  
  9.   * @author cwin5  
  10.   */  
  11.  public class MouseWheelFilter    
  12.  {   
  13.   /**  
  14.    * 是否启用  
  15.    */  
  16.   private static const ENABLE:Boolean = true;   
  17.      
  18.   /**  
  19.    * 设置过滤器  
  20.    * @param stage  
  21.    */  
  22.   public static function setFilter():void  
  23.   {   
  24.    if (!ENABLE)   
  25.     return;   
  26.       
  27.    if (ExternalInterface.available)   
  28.    {   
  29.     ExternalInterface.call(eval, var _onFlashMousewheel = function(e){   
  30.            + e = e || event;e.preventDefault && e.preventDefault();   
  31.             + e.stopPropagation && e.stopPropagation();    
  32.             + return e.returnValue = false;   
  33.             + };   
  34.             + if(window.addEventListener){   
  35.             + var type = (document.getBoxObjectFor)?\’DOMMouseScroll\’:\’mousewheel\’;   
  36.             + window.addEventListener(type, _onFlashMousewheel, false);}   
  37.             + else{document.onmousewheel = _onFlashMousewheel;});   
  38.    }   
  39.   }   
  40.      
  41.      
  42.      
  43.  }   
  44.     
  45. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值