package be.nascom.flash.threeD{ import be.nascom.util.MathFunctions; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; import flash.events.MouseEvent; import flash.geom.Rectangle; //public class graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator extends Rectangle implements IEventDispatcher{ public class graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator extends Rectangle{ protected var _event_dispatcher:EventDispatcher; protected var _speed:Number=5; protected var _hmiddle:Number; protected var _vmiddle:Number; protected var _hmap_min:Number; protected var _hmap_max:Number; protected var _vmap_min:Number; protected var _vmap_max:Number; protected var _x_rotation_speed:Number=0; public function get x_rotation_speed():Number{return _x_rotation_speed;} protected var _y_rotation_speed:Number=0; public function get y_rotation_speed():Number{return _y_rotation_speed;} protected var _z_rotation_speed:Number=0; public function get z_rotation_speed():Number{return _z_rotation_speed;} public function graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator(x:Number,y:Number,width:Number,height:Number,speed:Number){ trace("graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator"); super(x,y,width,height); _speed=speed; _hmiddle=x+width/2; _vmiddle=y+height/2; _hmap_min=x-_hmiddle; _hmap_max=width-_hmiddle; _vmap_min=y-_vmiddle; _vmap_max=height-_vmiddle; _event_dispatcher=new EventDispatcher(); } /* public function addEventListener(type:String,listener:Function,useCapture:Boolean=false,priority:int=0,useWeakReference:Boolean=false):void{ _event_dispatcher.addEventListener(type,listener,useCapture,priority,useWeakReference); } public function removeEventListener(type:String,listener:Function,useCapture:Boolean=false):void{ _event_dispatcher.removeEventListener(type,listener,useCapture); } public function dispatchEvent(event:Event):Boolean{ //trace("graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator.dispatchEvent , e:"+event.toString()); return _event_dispatcher.dispatchEvent(event.clone()); } public function hasEventListener(type:String):Boolean{ return _event_dispatcher.hasEventListener(type); } public function willTrigger(type:String):Boolean{ return _event_dispatcher.willTrigger(type); } */ public function update(e:MouseEvent):void{ //trace("graphic_player_10_cube_be_nascom_flash_threeD_MouseRotator.update(x:"+e.stageX+" , y:"+e.stageY+")"); if(this.contains(e.stageX,e.stageY)){ /* var re:Rotation3dEvent=new Rotation3dEvent(Rotation3dEvent.ROTATION_COMMAND); re.rotationX=MathFunctions.map(e.stageX-_hmiddle,_hmap_min,_hmap_max,-_speed,_speed); re.rotationY=MathFunctions.map(e.stageY-_vmiddle,_vmap_min,_vmap_max,-_speed,_speed); re.rotationZ=0; dispatchEvent(re); */ _x_rotation_speed=MathFunctions.map(e.stageY-_vmiddle,_vmap_min,_vmap_max,-_speed,_speed); _y_rotation_speed=MathFunctions.map(e.stageX-_hmiddle,_hmap_min,_hmap_max,-_speed,_speed); _z_rotation_speed=0; } } } }