home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DSS145 / DSS145_10 / DSS145_10.swf / scripts / Cursor.as < prev    next >
Text File  |  2012-07-18  |  3KB  |  125 lines

  1. package
  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 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.       public function Cursor(param1:MovieClip, param2:DisplayObjectContainer)
  24.       {
  25.          super();
  26.          this._cursorLib = param1;
  27.          this._cursorLib.mouseChildren = false;
  28.          this._cursorLib.mouseEnabled = false;
  29.          this._cursorLib.enabled = false;
  30.          this._parent = param2;
  31.          this._timer = new Timer(1,0);
  32.          this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
  33.       }
  34.       
  35.       public function set cursor(param1:String) : void
  36.       {
  37.          this._cursorName = param1;
  38.          switch(param1)
  39.          {
  40.             case "fleche":
  41.             case "doigt":
  42.                if(this._cursorLib.parent === this._parent)
  43.                {
  44.                   this._cursorLib.parent.removeChild(this._cursorLib);
  45.                }
  46.                this._timer.stop();
  47.                Mouse.show();
  48.                break;
  49.             default:
  50.                Mouse.hide();
  51.                this._cursorLib.gotoAndStop(this._cursorName);
  52.                if(this._cursorLib.parent !== this._parent)
  53.                {
  54.                   this._parent.addChild(this._cursorLib);
  55.                }
  56.                if(this._lock == false)
  57.                {
  58.                   this._timer.start();
  59.                }
  60.          }
  61.       }
  62.       
  63.       private function timerHandler(param1:TimerEvent) : void
  64.       {
  65.          this._cursorLib.x = this._cursorLib.stage.mouseX;
  66.          this._cursorLib.y = this._cursorLib.stage.mouseY;
  67.          param1.updateAfterEvent();
  68.       }
  69.       
  70.       public function destroy() : void
  71.       {
  72.          this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
  73.       }
  74.       
  75.       public function get x() : Number
  76.       {
  77.          return this._cursorLib.x;
  78.       }
  79.       
  80.       public function set x(param1:Number) : void
  81.       {
  82.          this._cursorLib.x = param1;
  83.       }
  84.       
  85.       public function get y() : Number
  86.       {
  87.          return this._cursorLib.y;
  88.       }
  89.       
  90.       public function set y(param1:Number) : void
  91.       {
  92.          this._cursorLib.y = param1;
  93.       }
  94.       
  95.       public function get lock() : Boolean
  96.       {
  97.          return this._lock;
  98.       }
  99.       
  100.       public function set lock(param1:Boolean) : void
  101.       {
  102.          if(this._lock == param1)
  103.          {
  104.             return;
  105.          }
  106.          this._lock = param1;
  107.          switch(this._cursorName)
  108.          {
  109.             case "fleche":
  110.             case "doigt":
  111.                break;
  112.             default:
  113.                if(this._lock == true)
  114.                {
  115.                   this._timer.stop();
  116.                }
  117.                else
  118.                {
  119.                   this._timer.start();
  120.                }
  121.          }
  122.       }
  123.    }
  124. }
  125.