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 >
Encoding:
Text File  |  2010-02-24  |  5.8 KB  |  186 lines

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