home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 148 / MOBICLIC148.ISO / mac / DATA / DSS148 / DSS148_01 / DSS148_01.swf / scripts / dss148 / Cursor.as < prev    next >
Text File  |  2012-10-16  |  4KB  |  135 lines

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