topical media & game development

talk show tell print

#graphic-player-10-cube-be-nascom-flash-threeD-MouseRotator.ax

#graphic-player-10-cube-be-nascom-flash-threeD-MouseRotator.ax [swf] [flash] flex


  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 @ax-graphic-player-10-cube-be-nascom-flash-threeD-MouseRotator extends Rectangle implements IEventDispatcher{
          public class @ax-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 @ax-graphic-player-10-cube-be-nascom-flash-threeD-MouseRotator(x:Number,y:Number,width:Number,height:Number,speed:Number){
                          trace("@ax-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("@ax-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("@ax-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;
                          }
                  }
                  
                  
          }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.