home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Swf / linux.swf / scripts / __Packages / com / rightactionscript / fcb / components / ScrollPane.as < prev    next >
Text File  |  2010-02-24  |  6KB  |  174 lines

  1. class com.rightactionscript.fcb.components.ScrollPane extends com.rightactionscript.fcb.components.UIBasicComponent
  2. {
  3.    function ScrollPane()
  4.    {
  5.       super();
  6.    }
  7.    function set scaleTo(oScaleTo)
  8.    {
  9.       this._oScaleTo = oScaleTo;
  10.    }
  11.    function get bytesLoaded()
  12.    {
  13.       return this._ldrContent.__get__bytesLoaded();
  14.    }
  15.    function get bytesTotal()
  16.    {
  17.       return this._ldrContent.__get__bytesTotal();
  18.    }
  19.    function get percentLoaded()
  20.    {
  21.       var _loc2_ = Math.round(this.__get__bytesLoaded() / this.__get__bytesTotal() * 100);
  22.       _loc2_ = !isNaN(_loc2_) ? _loc2_ : 0;
  23.       return _loc2_;
  24.    }
  25.    function init()
  26.    {
  27.       super.init();
  28.    }
  29.    function createChildren()
  30.    {
  31.       super.createChildren();
  32.       this.createEmptyMovieClip("_mcFrame",this.getNextHighestDepth());
  33.       this.attachMovie("Loader","_ldrContent",this.getNextHighestDepth());
  34.       this.attachMovie("ScrollBar","_sbVertical",this.getNextHighestDepth());
  35.       this.attachMovie("ScrollBar","_sbHorizontal",this.getNextHighestDepth());
  36.       this.createEmptyMovieClip("_mcMask",this.getNextHighestDepth());
  37.       this._sbVertical.setScrollProperties(10,0,100);
  38.       this._sbVertical.setSize(null,100 - this._sbVertical._width);
  39.       this._sbHorizontal.setScrollProperties(10,0,100);
  40.       this._sbHorizontal.setSize(null,100 - this._sbHorizontal._width);
  41.       this._sbHorizontal.__set__horizontal(true);
  42.       if(this.__width == undefined || this.__width == 0)
  43.       {
  44.          this.setSize(100,100);
  45.       }
  46.       this._ldrContent.__set__scaleContent(false);
  47.       this._ldrContent.addEventListener("complete",this);
  48.       this._ldrContent.__set__autoLoad(false);
  49.       if(this._sURL != undefined)
  50.       {
  51.          this.load();
  52.       }
  53.       this.mcBoundingBox._visible = false;
  54.       this.mcBoundingBox._width = 0;
  55.       this.mcBoundingBox._height = 0;
  56.    }
  57.    function draw()
  58.    {
  59.       var _loc3_ = this.__width - this._sbVertical._width;
  60.       var _loc2_ = this.__height - this._sbHorizontal._height;
  61.       this._mcMask.clear();
  62.       this._mcMask.lineStyle(0,0,0);
  63.       this._mcMask.beginFill(0,0);
  64.       this._mcMask.lineTo(_loc3_,0);
  65.       this._mcMask.lineTo(_loc3_,_loc2_);
  66.       this._mcMask.lineTo(0,_loc2_);
  67.       this._mcMask.lineTo(0,0);
  68.       this._mcMask.endFill(0);
  69.       this._mcFrame.clear();
  70.       this._mcFrame.lineStyle(0,15790065,100);
  71.       this._mcFrame.beginFill(16777215,100);
  72.       this._mcFrame.lineTo(this.__width - 1,0);
  73.       this._mcFrame.lineTo(this.__width - 1,this.__height - 1);
  74.       this._mcFrame.lineTo(0,this.__height - 1);
  75.       this._mcFrame.lineTo(0,0);
  76.       this._mcFrame.endFill();
  77.    }
  78.    function arrange()
  79.    {
  80.       this._sbVertical.setSize(null,this.__height - this._sbVertical._width);
  81.       this._sbHorizontal.setSize(null,this.__width - this._sbHorizontal._height);
  82.       this._sbVertical._x = this.__width - this._sbVertical._width;
  83.       this._sbHorizontal._y = this.__height;
  84.    }
  85.    function size()
  86.    {
  87.       super.size();
  88.       this.draw();
  89.       this.arrange();
  90.    }
  91.    function scroll(oEvent)
  92.    {
  93.       if(oEvent.target == this._sbHorizontal)
  94.       {
  95.          this._ldrContent._x = - oEvent.target.scrollPosition;
  96.       }
  97.       if(oEvent.target == this._sbVertical)
  98.       {
  99.          this._ldrContent._y = - oEvent.target.scrollPosition;
  100.       }
  101.    }
  102.    function complete(oEvent)
  103.    {
  104.       var _loc5_ = this.__height / oEvent.target._height;
  105.       var _loc6_ = this.__width / oEvent.target._width;
  106.       var _loc4_ = oEvent.target._width - this.__width;
  107.       var _loc3_ = oEvent.target._height - this.__height;
  108.       this._sbHorizontal.setScrollProperties(_loc6_ * _loc4_,0,_loc4_);
  109.       this._sbHorizontal.addEventListener("scroll",this);
  110.       this._sbVertical.setScrollProperties(_loc5_ * _loc3_,0,_loc3_);
  111.       this._sbVertical.addEventListener("scroll",this);
  112.       if(oEvent.target._width == 0)
  113.       {
  114.          oEvent.target.contentPath = "ScrollPaneSimpleFill";
  115.          oEvent.target.load();
  116.       }
  117.       oEvent.target.setMask(this._mcMask);
  118.       this.dispatchEvent({type:"complete",target:this});
  119.    }
  120.    function set contentPath(sURL)
  121.    {
  122.       this._sURL = sURL;
  123.       if(this._ldrContent != undefined)
  124.       {
  125.          this.load();
  126.       }
  127.    }
  128.    function set scrollContent(mcContent)
  129.    {
  130.       if(typeof mcContent == "string")
  131.       {
  132.          mcContent = eval(mcContent);
  133.       }
  134.       this._mcContent = mcContent;
  135.       this.load();
  136.    }
  137.    function get content()
  138.    {
  139.       return this._ldrContent.__get__content();
  140.    }
  141.    function load()
  142.    {
  143.       if(this._mcContent instanceof MovieClip)
  144.       {
  145.          this._mcContent._x = this._x;
  146.          this._mcContent._y = this._y;
  147.       }
  148.       else
  149.       {
  150.          if(this._sURL == "EmptyMovieClip")
  151.          {
  152.             this._sURL = "ScrollPaneSimpleFill";
  153.          }
  154.          this._ldrContent.__set__contentPath(this._sURL);
  155.          this._ldrContent.load();
  156.          this._ldrContent.addEventListener("complete",this);
  157.          this._ldrContent.addEventListener("progress",this);
  158.       }
  159.    }
  160.    function progress(oEvent)
  161.    {
  162.       this.dispatchEvent({type:"progress",target:this});
  163.    }
  164.    function refreshPane()
  165.    {
  166.       var _loc4_ = this.__height / this._ldrContent._height;
  167.       var _loc5_ = this.__width / this._ldrContent._height;
  168.       var _loc3_ = this._ldrContent._height - this.__width + this._sbVertical._width;
  169.       var _loc2_ = this._ldrContent._height - this.__height + this._sbHorizontal._height;
  170.       this._sbHorizontal.setScrollProperties(_loc5_ * _loc3_,0,_loc3_);
  171.       this._sbVertical.setScrollProperties(_loc4_ * _loc2_,0,_loc2_);
  172.    }
  173. }
  174.