home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / Clusterz / Clusterz.swf / scripts / ENGINE / INTERFACE / OIObject.as < prev    next >
Encoding:
Text File  |  2008-09-12  |  10.2 KB  |  364 lines

  1. package ENGINE.INTERFACE
  2. {
  3.    import ENGINE.CORE.OGlobal;
  4.    import ENGINE.DISPLAY.IDisplayObject;
  5.    import ENGINE.DISPLAY.OSprite;
  6.    import ENGINE.INTERFACE.ANIMATORS.OAnimatorManager;
  7.    import flash.display.DisplayObject;
  8.    import flash.events.*;
  9.    import flash.geom.Rectangle;
  10.    
  11.    public class OIObject extends OSprite
  12.    {
  13.       
  14.       public static var trActive:uint = 2;
  15.       
  16.       public static var trPress:uint = 16;
  17.       
  18.       public static var trRool:uint = 8;
  19.       
  20.       public static var trFocus:uint = 3;
  21.       
  22.       public static var trVisible:uint = 1;
  23.        
  24.       
  25.       protected var iTrigger:uint;
  26.       
  27.       protected var iAEnabled:Boolean = true;
  28.       
  29.       protected var iAManager:OAnimatorManager;
  30.       
  31.       protected var iState:int;
  32.       
  33.       protected var iAParams:Array;
  34.       
  35.       protected var iParam:Array;
  36.       
  37.       public function OIObject(param1:Array, param2:Array = null)
  38.       {
  39.          iTrigger = trVisible | trActive;
  40.          iAEnabled = true;
  41.          super();
  42.          this.iParam = param1;
  43.          this.iAParams = param2;
  44.          this.Init();
  45.       }
  46.       
  47.       public function get prMouseEnabled() : Boolean
  48.       {
  49.          return this.prVisible && this.prActive;
  50.       }
  51.       
  52.       public function get prRool() : Boolean
  53.       {
  54.          return (this.iTrigger & trRool) > 0;
  55.       }
  56.       
  57.       public function set prFocus(param1:Boolean) : void
  58.       {
  59.          if(param1)
  60.          {
  61.             this.iTrigger |= trFocus;
  62.             if(this.iAManager)
  63.             {
  64.                this.AddAnimator(this.iAParams[OAnimatorManager.anFocusIn]);
  65.             }
  66.          }
  67.          else
  68.          {
  69.             this.iTrigger &= ~trFocus;
  70.             if(this.iAManager)
  71.             {
  72.                this.AddAnimator(this.iAParams[OAnimatorManager.anFocusOut]);
  73.             }
  74.          }
  75.       }
  76.       
  77.       override public function get prVisible() : Boolean
  78.       {
  79.          return (this.iTrigger & trVisible) > 0;
  80.       }
  81.       
  82.       public function set prRool(param1:Boolean) : void
  83.       {
  84.          if(param1)
  85.          {
  86.             this.iTrigger |= trRool;
  87.             if(this.iAManager)
  88.             {
  89.                this.AddAnimator(this.iAParams[OAnimatorManager.anRoolOver]);
  90.             }
  91.          }
  92.          else
  93.          {
  94.             this.iTrigger &= ~trRool;
  95.             if(this.iAManager)
  96.             {
  97.                this.AddAnimator(this.iAParams[OAnimatorManager.anRoolOut]);
  98.             }
  99.          }
  100.       }
  101.       
  102.       override public function set prVisible(param1:Boolean) : void
  103.       {
  104.          if(param1)
  105.          {
  106.             this.iTrigger |= trVisible;
  107.             if(this.iAManager)
  108.             {
  109.                this.AddAnimator(this.iAParams[OAnimatorManager.anShow],false);
  110.             }
  111.          }
  112.          else
  113.          {
  114.             this.iTrigger &= ~trVisible;
  115.             if(this.iAManager)
  116.             {
  117.                this.AddAnimator(this.iAParams[OAnimatorManager.anHide],false);
  118.             }
  119.          }
  120.          if(!this.iAManager || !this.iAEnabled)
  121.          {
  122.             this.visible = param1;
  123.          }
  124.          this.mouseEnabled = this.prMouseEnabled;
  125.          this.mouseChildren = this.mouseEnabled;
  126.       }
  127.       
  128.       public function OnRollOver(param1:MouseEvent) : void
  129.       {
  130.          this.prRool = true;
  131.       }
  132.       
  133.       public function Init() : void
  134.       {
  135.          var _loc1_:int = 0;
  136.          var _loc2_:int = 0;
  137.          var _loc3_:int = 0;
  138.          var _loc4_:DisplayObject = null;
  139.          var _loc5_:String = null;
  140.          if(this.iParam)
  141.          {
  142.             _loc1_ = int(this.iParam.length);
  143.             _loc2_ = 0;
  144.             while(_loc2_ < _loc1_)
  145.             {
  146.                _loc3_ = int(this.iParam[_loc2_].length);
  147.                _loc4_ = this.iParam[_loc2_][0](this.iParam[_loc2_]);
  148.                if(_loc5_ = String(this.iParam[_loc2_][_loc3_ - 3]))
  149.                {
  150.                   if(this[_loc5_] is Array)
  151.                   {
  152.                      this[_loc5_][this.iParam[_loc2_][_loc3_ - 2]] = _loc4_;
  153.                   }
  154.                   else
  155.                   {
  156.                      this[_loc5_] = _loc4_;
  157.                   }
  158.                }
  159.                if(_loc4_ is OIObject)
  160.                {
  161.                   (_loc4_ as OIObject).SetVisible(this.iParam[_loc2_][_loc3_ - 1]);
  162.                }
  163.                else if(_loc4_ is IDisplayObject)
  164.                {
  165.                   (_loc4_ as IDisplayObject).prVisible = this.iParam[_loc2_][_loc3_ - 1];
  166.                }
  167.                else
  168.                {
  169.                   _loc4_.visible = this.iParam[_loc2_][_loc3_ - 1];
  170.                }
  171.                this.addChild(_loc4_);
  172.                _loc2_++;
  173.             }
  174.          }
  175.          this.iAManager = !!this.iAParams ? new OAnimatorManager(this) : null;
  176.          this.tabEnabled = false;
  177.          this.addEventListener(Event.ENTER_FRAME,OnEnterFrame);
  178.          this.addEventListener(MouseEvent.ROLL_OVER,OnRollOver);
  179.          this.addEventListener(MouseEvent.ROLL_OUT,OnRollOut);
  180.          this.addEventListener(MouseEvent.MOUSE_DOWN,OnMouseDown);
  181.          this.addEventListener(MouseEvent.MOUSE_UP,OnMouseUp);
  182.       }
  183.       
  184.       public function get prAnimationEnabled() : Boolean
  185.       {
  186.          return this.iAEnabled;
  187.       }
  188.       
  189.       public function set prActive(param1:Boolean) : void
  190.       {
  191.          if(param1)
  192.          {
  193.             this.iTrigger |= trActive;
  194.             if(this.iAManager)
  195.             {
  196.                this.AddAnimator(this.iAParams[OAnimatorManager.anActivate]);
  197.             }
  198.          }
  199.          else
  200.          {
  201.             this.iTrigger &= ~trActive;
  202.             if(this.iAManager)
  203.             {
  204.                this.AddAnimator(this.iAParams[OAnimatorManager.anDeactivate]);
  205.             }
  206.          }
  207.          this.mouseEnabled = this.prMouseEnabled;
  208.          this.mouseChildren = this.mouseEnabled;
  209.       }
  210.       
  211.       public function OnMouseUp(param1:MouseEvent) : void
  212.       {
  213.          this.prPress = false;
  214.       }
  215.       
  216.       public function get prPress() : Boolean
  217.       {
  218.          return (this.iTrigger & trPress) > 0;
  219.       }
  220.       
  221.       public function get State() : int
  222.       {
  223.          return this.iState;
  224.       }
  225.       
  226.       public function OnPress(param1:Event, param2:*) : void
  227.       {
  228.       }
  229.       
  230.       public function OnRollOut(param1:MouseEvent) : void
  231.       {
  232.          this.prRool = false;
  233.       }
  234.       
  235.       override public function Free() : void
  236.       {
  237.          this.removeEventListener(MouseEvent.MOUSE_UP,OnMouseUp);
  238.          this.removeEventListener(MouseEvent.MOUSE_DOWN,OnMouseDown);
  239.          this.removeEventListener(MouseEvent.ROLL_OUT,OnRollOut);
  240.          this.removeEventListener(MouseEvent.ROLL_OVER,OnRollOver);
  241.          this.removeEventListener(Event.ENTER_FRAME,OnEnterFrame);
  242.          super.Free();
  243.          if(this.iAManager)
  244.          {
  245.             this.iAManager.Free();
  246.          }
  247.          this.iAManager = null;
  248.       }
  249.       
  250.       public function get prAnimation() : Boolean
  251.       {
  252.          var _loc1_:int = 0;
  253.          if(Boolean(this.iAManager) && this.iAManager.prAnimation)
  254.          {
  255.             return true;
  256.          }
  257.          _loc1_ = 0;
  258.          while(_loc1_ < this.numChildren)
  259.          {
  260.             if(this.getChildAt(_loc1_) is OIObject)
  261.             {
  262.                if((this.getChildAt(_loc1_) as OIObject).prAnimation)
  263.                {
  264.                   return true;
  265.                }
  266.             }
  267.             _loc1_++;
  268.          }
  269.          return false;
  270.       }
  271.       
  272.       public function get prActive() : Boolean
  273.       {
  274.          return (this.iTrigger & trActive) > 0;
  275.       }
  276.       
  277.       public function PosCenter(param1:Number = 800, param2:Number = 600) : void
  278.       {
  279.          var _loc3_:Rectangle = null;
  280.          _loc3_ = this.getBounds(this);
  281.          this.Pos(OGlobal.ScaleFloor((param1 - this.prWidth - OGlobal.ToLocal(_loc3_.x) * 2) / 2),OGlobal.ScaleFloor((param2 - this.prHeight - OGlobal.ToLocal(_loc3_.y) * 2) / 2));
  282.       }
  283.       
  284.       public function AddAnimator(param1:Object, param2:Boolean = true) : void
  285.       {
  286.          var _loc3_:Boolean = false;
  287.          _loc3_ = param2 ? Boolean(this.iAManager) && this.prVisible && this.iAEnabled : Boolean(this.iAManager) && this.iAEnabled;
  288.          if(_loc3_)
  289.          {
  290.             this.iAManager.AddAnimator(param1);
  291.          }
  292.       }
  293.       
  294.       public function set prAnimationEnabled(param1:Boolean) : void
  295.       {
  296.          this.iAEnabled = param1;
  297.       }
  298.       
  299.       public function set prPress(param1:Boolean) : void
  300.       {
  301.          if(param1)
  302.          {
  303.             this.iTrigger |= trPress;
  304.             if(this.iAManager)
  305.             {
  306.                this.AddAnimator(this.iAParams[OAnimatorManager.anPress]);
  307.             }
  308.          }
  309.          else
  310.          {
  311.             this.iTrigger &= ~trPress;
  312.             if(this.iAManager)
  313.             {
  314.                this.AddAnimator(this.iAParams[OAnimatorManager.anUnpress]);
  315.             }
  316.          }
  317.       }
  318.       
  319.       public function OnMouseDown(param1:MouseEvent) : void
  320.       {
  321.          this.prPress = true;
  322.       }
  323.       
  324.       public function OnEnterFrame(param1:Event) : void
  325.       {
  326.          if(this.iAManager)
  327.          {
  328.             this.iAManager.OnEnterFrame();
  329.          }
  330.       }
  331.       
  332.       public function SetVisible(param1:Boolean) : void
  333.       {
  334.          this.prAnimationEnabled = false;
  335.          this.prVisible = param1;
  336.          this.prAnimationEnabled = true;
  337.       }
  338.       
  339.       public function set prAnimatorParams(param1:Array) : void
  340.       {
  341.          this.iAParams = param1;
  342.          if(!this.iAManager)
  343.          {
  344.             this.iAManager = new OAnimatorManager(this);
  345.          }
  346.       }
  347.       
  348.       public function set State(param1:int) : void
  349.       {
  350.          this.iState = param1;
  351.       }
  352.       
  353.       public function get prAnimatorParams() : Array
  354.       {
  355.          return this.iAParams;
  356.       }
  357.       
  358.       public function get prFocus() : Boolean
  359.       {
  360.          return (this.iTrigger & trFocus) > 0;
  361.       }
  362.    }
  363. }
  364.