Показать сообщение отдельно
Старый 14.04.2010, 12:36
random13 вне форума Посмотреть профиль Отправить личное сообщение для random13 Найти все сообщения от random13
  № 10  
Ответить с цитированием
random13
 
Аватар для random13

Регистрация: Oct 2006
Адрес: Москва
Сообщений: 889
такое произошло в следующей ситуации, пользуюсь наработками товарища etcs по работе с скролом + плюс кое что свое и чужое, вот что получилось:

Код AS3:
package libraries
{
	import flash.display.InteractiveObject;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.geom.Point;
	import flash.geom.Rectangle;
 
	import spark.primitives.Rect;
 
	public class CustomMouseWheel
	{
		private static var _instance:CustomMouseWheel;
		private var _stage:Stage;
		private var _cloneEvent:MouseEvent;
		private var _lastCoord:Point;
 
		public function CustomMouseWheel(singletoniser:Singletoniser) {
			if(singletoniser == null) {
				throw new Error('This is singleton class, use getInstance() instead');
			}
		}
 
		public static function getInstance():CustomMouseWheel
		{
			CustomMouseWheel._instance ? CustomMouseWheel._instance : CustomMouseWheel._instance = new CustomMouseWheel( new Singletoniser() );
			return CustomMouseWheel._instance;
		}
 
		public static function setup(stage:Stage):void {
			CustomMouseWheel.getInstance()._setup(stage);			
		}
 
		private function _setup(stage:Stage):void {
			this._stage = stage;
			this._stage.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this._stage.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			this._stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
			ExternalInterface.addCallback('sendMouseWheelEvent', externalMouseEvent);
		}
 
		private function onMouseOver(e:MouseEvent):void {
			this._stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
 
		private function onMouseOut(e:MouseEvent):void {
			this._stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
 
		private function onMouseMove(e:MouseEvent):void {
			this._lastCoord = new Point(e.stageX,e.stageY);
			this._cloneEvent = MouseEvent(e);
		}
 
		private function externalMouseEvent(delta:Number):void {
			if(delta > 0 && delta < 1)
				delta = 1;
			else if(delta > -1 && delta < 0)
				delta = -1;
 
			var wheelEvent:MouseEvent = new MouseEvent(
				MouseEvent.MOUSE_WHEEL,
				true,
				false,
//				this._cloneEvent.stageX,
//				this._cloneEvent.stageY,
				this._lastCoord.x,
				this._lastCoord.y,
				this._cloneEvent.relatedObject,
				this._cloneEvent.ctrlKey,
				this._cloneEvent.altKey,
				this._cloneEvent.shiftKey,
				this._cloneEvent.buttonDown,
				delta
			);
			this._stage.dispatchEvent(wheelEvent);
		}
	}
}
 
class Singletoniser {}
про координаты как я уже писал изменялись вот тут

Код AS3:
//				this._cloneEvent.stageX,
//				this._cloneEvent.stageY,
				this._lastCoord.x,
				this._lastCoord.y,
поэтому собственно закоменчено и добавлена точка
__________________
Коллекционирую чужие ActionScript Блоги