home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 161 / MOBICLIC161.ISO / pc / DATA / DSS161 / DSS161_00 / DSS161_00.swf / scripts / dss161 / engineaddons / gamesprotos / actors / cursor / Cursor.as
Text File  |  2014-01-15  |  4KB  |  152 lines

  1. package dss161.engineaddons.gamesprotos.actors.cursor
  2. {
  3.    import flash.display.DisplayObjectContainer;
  4.    import flash.display.MovieClip;
  5.    import flash.events.TimerEvent;
  6.    import flash.ui.Mouse;
  7.    import flash.utils.Timer;
  8.    
  9.    public dynamic class Cursor
  10.    {
  11.        
  12.       
  13.       private var _parent:DisplayObjectContainer;
  14.       
  15.       private var _cursorLib:MovieClip;
  16.       
  17.       private var _cursorName:String = "fleche";
  18.       
  19.       private var _timer:Timer;
  20.       
  21.       private var _lock:Boolean = false;
  22.       
  23.       private var _mouseVisible:Boolean = true;
  24.       
  25.       public function Cursor(param1:MovieClip = null, param2:DisplayObjectContainer = null)
  26.       {
  27.          super();
  28.          this._cursorLib = param1;
  29.          this._cursorLib.mouseChildren = false;
  30.          this._cursorLib.mouseEnabled = false;
  31.          this._cursorLib.enabled = false;
  32.          this._parent = param2;
  33.          if(param1 != null)
  34.          {
  35.          }
  36.          this._timer = new Timer(1,0);
  37.          this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
  38.       }
  39.       
  40.       public function change(param1:String) : void
  41.       {
  42.          this._cursorName = param1;
  43.          switch(param1)
  44.          {
  45.             case "fleche":
  46.             case "doigt":
  47.                this._cursorLib.visible = false;
  48.                if(this._cursorLib.parent === this._parent)
  49.                {
  50.                   this._cursorLib.parent.removeChild(this._cursorLib);
  51.                }
  52.                this._timer.stop();
  53.                this.mouseVisible = true;
  54.                break;
  55.             default:
  56.                this.mouseVisible = false;
  57.                this._cursorLib.gotoAndStop(this._cursorName);
  58.                if(this._cursorLib.parent !== this._parent)
  59.                {
  60.                   this._parent.addChild(this._cursorLib);
  61.                }
  62.                this._cursorLib.x = this._cursorLib.stage.mouseX;
  63.                this._cursorLib.y = this._cursorLib.stage.mouseY;
  64.                if(this._lock == false)
  65.                {
  66.                   this._timer.start();
  67.                }
  68.                this._cursorLib.visible = true;
  69.          }
  70.       }
  71.       
  72.       private function timerHandler(param1:TimerEvent) : void
  73.       {
  74.          this._cursorLib.x = this._cursorLib.stage.mouseX;
  75.          this._cursorLib.y = this._cursorLib.stage.mouseY;
  76.          param1.updateAfterEvent();
  77.       }
  78.       
  79.       public function destroy() : void
  80.       {
  81.          this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
  82.       }
  83.       
  84.       public function get x() : Number
  85.       {
  86.          return this._cursorLib.x;
  87.       }
  88.       
  89.       public function set x(param1:Number) : void
  90.       {
  91.          this._cursorLib.x = param1;
  92.       }
  93.       
  94.       public function get y() : Number
  95.       {
  96.          return this._cursorLib.y;
  97.       }
  98.       
  99.       public function set y(param1:Number) : void
  100.       {
  101.          this._cursorLib.y = param1;
  102.       }
  103.       
  104.       public function get lock() : Boolean
  105.       {
  106.          return this._lock;
  107.       }
  108.       
  109.       public function set lock(param1:Boolean) : void
  110.       {
  111.          if(this._lock == param1)
  112.          {
  113.             return;
  114.          }
  115.          this._lock = param1;
  116.          switch(this._cursorName)
  117.          {
  118.             case "fleche":
  119.             case "doigt":
  120.                break;
  121.             default:
  122.                if(this._lock == true)
  123.                {
  124.                   this._timer.stop();
  125.                }
  126.                else
  127.                {
  128.                   this._timer.start();
  129.                }
  130.          }
  131.       }
  132.       
  133.       public function set mouseVisible(param1:Boolean) : void
  134.       {
  135.          this._mouseVisible = param1;
  136.          if(this._mouseVisible)
  137.          {
  138.             Mouse.show();
  139.          }
  140.          else
  141.          {
  142.             Mouse.hide();
  143.          }
  144.       }
  145.       
  146.       public function get mouseVisible() : Boolean
  147.       {
  148.          return this._mouseVisible;
  149.       }
  150.    }
  151. }
  152.