home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / sky-chopper.swf / scripts / __Packages / mx / controls / menuclasses / MenuRow.as < prev   
Encoding:
Text File  |  2005-09-29  |  4.4 KB  |  148 lines

  1. class mx.controls.menuclasses.MenuRow extends mx.controls.listclasses.SelectableRow
  2. {
  3.    var cell;
  4.    var owner;
  5.    var icon_branch;
  6.    var branch;
  7.    var type;
  8.    var iconID;
  9.    var icon_mc;
  10.    var icon_sep;
  11.    var __width;
  12.    var __height;
  13.    var idealWidth;
  14.    var isEnabled = true;
  15.    var selected = false;
  16.    var lBuffer = 18;
  17.    var rBuffer = 15;
  18.    function MenuRow()
  19.    {
  20.       super();
  21.    }
  22.    function setValue(itemObj, sel)
  23.    {
  24.       var _loc7_ = this.cell;
  25.       var _loc6_ = this.itemToString(itemObj);
  26.       if(_loc7_.getValue() != _loc6_)
  27.       {
  28.          _loc7_.setValue(_loc6_,itemObj,this.state);
  29.       }
  30.       var _loc8_ = itemObj.hasChildNodes();
  31.       var _loc5_ = mx.controls.Menu.isItemEnabled(itemObj);
  32.       var _loc4_ = itemObj.attributes.type;
  33.       if(_loc4_ == undefined)
  34.       {
  35.          _loc4_ = "normal";
  36.       }
  37.       var _loc9_ = mx.controls.Menu.isItemSelected(itemObj);
  38.       var _loc3_ = this.owner.__iconFunction(itemObj);
  39.       if(_loc3_ == undefined)
  40.       {
  41.          _loc3_ = itemObj.attributes[this.owner.__iconField];
  42.       }
  43.       if(_loc3_ == undefined)
  44.       {
  45.          _loc3_ = this.owner.getStyle("defaultIcon");
  46.       }
  47.       if(this.icon_branch && (_loc8_ != this.branch || _loc5_ != this.isEnabled || this.type == "separator"))
  48.       {
  49.          this.icon_branch.removeMovieClip();
  50.          delete this.icon_branch;
  51.       }
  52.       if(_loc9_ != this.selected || _loc3_ != this.iconID || _loc4_ != this.type || _loc5_ != this.isEnabled && _loc4_ != "normal")
  53.       {
  54.          this.icon_mc.removeMovieClip();
  55.          this.icon_sep.removeMovieClip();
  56.          delete this.icon_sep;
  57.          delete this.icon_mc;
  58.       }
  59.       this.branch = _loc8_;
  60.       this.isEnabled = _loc5_;
  61.       this.type = _loc4_;
  62.       this.selected = _loc9_;
  63.       this.iconID = _loc3_;
  64.       this.cell.__enabled = this.isEnabled;
  65.       this.cell.setColor(!this.isEnabled ? this.owner.getStyle("disabledColor") : this.owner.getStyle("color"));
  66.       if(sel == "highlighted")
  67.       {
  68.          if(this.isEnabled)
  69.          {
  70.             this.cell.setColor(this.owner.getStyle("textRollOverColor"));
  71.          }
  72.       }
  73.       else if(sel == "selected")
  74.       {
  75.          if(this.isEnabled)
  76.          {
  77.             this.cell.setColor(this.owner.getStyle("textSelectedColor"));
  78.          }
  79.       }
  80.       if(this.branch && this.icon_branch == undefined)
  81.       {
  82.          this.icon_branch = this.createObject("MenuBranch" + (!this.isEnabled ? "Disabled" : "Enabled"),"icon_branch",20);
  83.       }
  84.       if(this.type == "separator")
  85.       {
  86.          if(this.icon_sep == undefined)
  87.          {
  88.             var _loc10_ = this.createObject("MenuSeparator","icon_sep",21);
  89.          }
  90.       }
  91.       else if(this.icon_mc == undefined)
  92.       {
  93.          if(this.type != "normal")
  94.          {
  95.             if(this.selected)
  96.             {
  97.                this.iconID = (this.type != "check" ? "MenuRadio" : "MenuCheck") + (!this.isEnabled ? "Disabled" : "Enabled");
  98.             }
  99.             else
  100.             {
  101.                this.iconID = undefined;
  102.             }
  103.          }
  104.          if(this.iconID != undefined)
  105.          {
  106.             this.icon_mc = this.createObject(this.iconID,"icon_mc",21);
  107.          }
  108.       }
  109.       this.size();
  110.    }
  111.    function itemToString(itmObj)
  112.    {
  113.       if(itmObj.attributes.type == "separator")
  114.       {
  115.          return " ";
  116.       }
  117.       return super.itemToString(itmObj);
  118.    }
  119.    function size(Void)
  120.    {
  121.       super.size();
  122.       this.cell._x = this.lBuffer;
  123.       this.cell.setSize(this.__width - this.rBuffer - this.lBuffer,Math.min(this.__height,this.cell.getPreferredHeight()));
  124.       if(this.icon_branch)
  125.       {
  126.          this.icon_branch._x = this.__width - this.rBuffer / 2;
  127.          this.icon_branch._y = (this.__height - this.icon_branch._height) / 2;
  128.       }
  129.       if(this.icon_sep)
  130.       {
  131.          this.icon_sep._x = 4;
  132.          this.icon_sep._y = (this.__height - this.icon_sep._height) / 2;
  133.          this.icon_sep._width = this.__width - 8;
  134.       }
  135.       else if(this.icon_mc)
  136.       {
  137.          this.icon_mc._x = Math.max(0,(this.lBuffer - this.icon_mc._width) / 2);
  138.          this.icon_mc._y = (this.__height - this.icon_mc._height) / 2;
  139.       }
  140.    }
  141.    function getIdealWidth(Void)
  142.    {
  143.       this.cell.draw();
  144.       this.idealWidth = this.cell.getPreferredWidth() + 4 + this.lBuffer + this.rBuffer;
  145.       return this.idealWidth;
  146.    }
  147. }
  148.