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

  1. class mx.controls.List extends mx.controls.listclasses.ScrollSelectList
  2. {
  3.    var border_mc;
  4.    var __labels;
  5.    var setDataProvider;
  6.    var __dataProvider;
  7.    var __maxHPosition;
  8.    var invScrollProps;
  9.    var __width;
  10.    var totalWidth;
  11.    var totalHeight;
  12.    var displayWidth;
  13.    var vScroller;
  14.    var listContent;
  15.    var data;
  16.    var mask_mc;
  17.    var __height;
  18.    var invRowHeight;
  19.    var invLayoutContent;
  20.    var oldVWidth;
  21.    static var symbolOwner = mx.controls.List;
  22.    static var symbolName = "List";
  23.    static var version = "2.0.0.360";
  24.    var clipParameters = {rowHeight:1,enabled:1,visible:1,labels:1};
  25.    var scrollDepth = 1;
  26.    var __vScrollPolicy = "on";
  27.    var autoHScrollAble = false;
  28.    function List()
  29.    {
  30.       super();
  31.    }
  32.    function setEnabled(v)
  33.    {
  34.       super.setEnabled(v);
  35.       this.border_mc.backgroundColorName = !v ? "backgroundDisabledColor" : "backgroundColor";
  36.       this.border_mc.invalidate();
  37.    }
  38.    function get labels()
  39.    {
  40.       return this.__labels;
  41.    }
  42.    function set labels(lbls)
  43.    {
  44.       this.__labels = lbls;
  45.       this.setDataProvider(lbls);
  46.    }
  47.    function setVPosition(pos)
  48.    {
  49.       pos = Math.min(this.__dataProvider.length - this.rowCount + this.roundUp,pos);
  50.       pos = Math.max(0,pos);
  51.       super.setVPosition(pos);
  52.    }
  53.    function setHPosition(pos)
  54.    {
  55.       pos = Math.max(Math.min(this.__maxHPosition,pos),0);
  56.       super.setHPosition(pos);
  57.       this.hScroll(pos);
  58.    }
  59.    function setMaxHPosition(pos)
  60.    {
  61.       this.__maxHPosition = pos;
  62.       this.invScrollProps = true;
  63.       this.invalidate();
  64.    }
  65.    function setHScrollPolicy(policy)
  66.    {
  67.       if(policy.toLowerCase() == "auto" && !this.autoHScrollAble)
  68.       {
  69.          return undefined;
  70.       }
  71.       super.setHScrollPolicy(policy);
  72.       if(policy == "off")
  73.       {
  74.          this.setHPosition(0);
  75.          this.setVPosition(Math.min(this.__dataProvider.length - this.rowCount + this.roundUp,this.__vPosition));
  76.       }
  77.    }
  78.    function setRowCount(rC)
  79.    {
  80.       if(isNaN(rC))
  81.       {
  82.          return undefined;
  83.       }
  84.       var _loc2_ = this.getViewMetrics();
  85.       this.setSize(this.__width,this.__rowHeight * rC + _loc2_.top + _loc2_.bottom);
  86.    }
  87.    function layoutContent(x, y, tW, tH, dW, dH)
  88.    {
  89.       this.totalWidth = tW;
  90.       this.totalHeight = tH;
  91.       this.displayWidth = dW;
  92.       var _loc4_ = !(this.__hScrollPolicy == "on" || this.__hScrollPolicy == "auto") ? dW : Math.max(tW,dW);
  93.       super.layoutContent(x,y,_loc4_,dH);
  94.    }
  95.    function modelChanged(eventObj)
  96.    {
  97.       super.modelChanged(eventObj);
  98.       var _loc3_ = eventObj.eventName;
  99.       if(_loc3_ == "addItems" || _loc3_ == "removeItems" || _loc3_ == "updateAll" || _loc3_ == "filterModel")
  100.       {
  101.          this.invScrollProps = true;
  102.          this.invalidate("invScrollProps");
  103.       }
  104.    }
  105.    function onScroll(eventObj)
  106.    {
  107.       var _loc3_ = eventObj.target;
  108.       if(_loc3_ == this.vScroller)
  109.       {
  110.          this.setVPosition(_loc3_.scrollPosition);
  111.       }
  112.       else
  113.       {
  114.          this.hScroll(_loc3_.scrollPosition);
  115.       }
  116.       super.onScroll(eventObj);
  117.    }
  118.    function hScroll(pos)
  119.    {
  120.       this.__hPosition = pos;
  121.       this.listContent._x = - pos;
  122.    }
  123.    function init(Void)
  124.    {
  125.       super.init();
  126.       if(this.labels.length > 0)
  127.       {
  128.          var _loc6_ = new Array();
  129.          var _loc3_ = 0;
  130.          while(_loc3_ < this.labels.length)
  131.          {
  132.             _loc6_.addItem({label:this.labels[_loc3_],data:this.data[_loc3_]});
  133.             _loc3_ = _loc3_ + 1;
  134.          }
  135.          this.setDataProvider(_loc6_);
  136.       }
  137.       this.__maxHPosition = 0;
  138.    }
  139.    function createChildren(Void)
  140.    {
  141.       super.createChildren();
  142.       this.listContent.setMask(this.mask_mc);
  143.       this.border_mc.move(0,0);
  144.       this.border_mc.setSize(this.__width,this.__height);
  145.    }
  146.    function getRowCount(Void)
  147.    {
  148.       var _loc2_ = this.getViewMetrics();
  149.       return this.__rowCount != 0 ? this.__rowCount : Math.ceil((this.__height - _loc2_.top - _loc2_.bottom) / this.__rowHeight);
  150.    }
  151.    function size(Void)
  152.    {
  153.       super.size();
  154.       this.configureScrolling();
  155.       var _loc3_ = this.getViewMetrics();
  156.       this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  157.    }
  158.    function draw(Void)
  159.    {
  160.       if(this.invRowHeight)
  161.       {
  162.          this.invScrollProps = true;
  163.          super.draw();
  164.          this.listContent.setMask(this.mask_mc);
  165.          this.invLayoutContent = true;
  166.       }
  167.       if(this.invScrollProps)
  168.       {
  169.          this.configureScrolling();
  170.          delete this.invScrollProps;
  171.       }
  172.       if(this.invLayoutContent)
  173.       {
  174.          var _loc3_ = this.getViewMetrics();
  175.          this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  176.       }
  177.       super.draw();
  178.    }
  179.    function configureScrolling(Void)
  180.    {
  181.       var _loc2_ = this.__dataProvider.length;
  182.       if(this.__vPosition > Math.max(0,_loc2_ - this.getRowCount() + this.roundUp))
  183.       {
  184.          this.setVPosition(Math.max(0,Math.min(_loc2_ - this.getRowCount() + this.roundUp,this.__vPosition)));
  185.       }
  186.       var _loc3_ = this.getViewMetrics();
  187.       var _loc4_ = this.__hScrollPolicy == "off" ? this.__width - _loc3_.left - _loc3_.right : this.__maxHPosition + this.__width - _loc3_.left - _loc3_.right;
  188.       if(_loc2_ == undefined)
  189.       {
  190.          _loc2_ = 0;
  191.       }
  192.       this.setScrollProperties(_loc4_,1,_loc2_,this.__rowHeight);
  193.       if(this.oldVWidth != _loc4_)
  194.       {
  195.          this.invLayoutContent = true;
  196.       }
  197.       this.oldVWidth = _loc4_;
  198.    }
  199. }
  200.