1  /**
     2   * com.sekati.external.MouseWheel
     3   * @version 1.0.7
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8  
     9  import com.sekati.events.Broadcaster;
    10  import com.sekati.net.NetBase;
    11  import com.sekati.validate.OSValidation;
    12  import flash.external.*;
    13  
    14  /**
    15   * MouseWheel support for Mac & PC. Requires: sasapi.js
    16   */
    17  class com.sekati.external.MouseWheel {
    18  
    19  	private static var _isMac:Boolean = OSValidation.isMac( );
    20  	private static var _cb:Boolean;
    21  
    22  	/**
    23  	 * initialize MouseWheel support for mac/pc and add object as Mouse listener
    24  	 * @param o (Object) to subscribe to onMouseWheel event
    25  	 * @return Void
    26  	 * {@code Usage:
    27  	 * 	MouseWheel.init(this);
    28  	 * }
    29  	 */
    30  	public static function init(o:Object):Void {
    31  		if(!_cb && _isMac) {
    32  			_cb = ExternalInterface.addCallback( "externalMouseEvent", MouseWheel, MouseWheel.externalMouseEvent );	
    33  		}
    34  		if(_isMac) {
    35  			Broadcaster.$.addListener( o );
    36  			if(!NetBase.isOnline( )) {
    37  				//throw new Error ("@@@ com.sekati.external.MouseWheel Error: init was called but swf is not online and does not have access to the sasapi.js library to make Mac MouseWheel function.");	
    38  			}
    39  		} else {
    40  			Mouse.addListener( o );
    41  		}
    42  	}
    43  
    44  	/**
    45  	 * Catch callback from javascript and broadcast MouseWheel event for Mac's
    46  	 * @param delta (Number)
    47  	 * @return Void
    48  	 */
    49  	private static function externalMouseEvent(delta:Number):Void {
    50  		Broadcaster.$.broadcast( "onMouseWheel", delta );	
    51  	}
    52  
    53  	private function MouseWheel() {	
    54  	}
    55  }