Adobe Systems, Inc.

ProgressBarThumb.as

Go to the documentation of this file.
00001 /****************************************
00002 ** Copyright 2005-2006 Adobe Systems Incorporated
00003 ** Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004 ** or a copy at http://opensource.adobe.com/licenses.html)
00005 **
00006 ** ProgressBarThumb Class 
00007 ****************************************/
00008 import amg.*;
00009 
00010 class amg.ProgressBarThumb extends MovieClip { 
00011         //member properties
00012         private var mcProgressBar:MovieClip;
00013         private var mcProgressBarOutline:MovieClip;
00014         private var _mcCanvas:MovieClip;
00015         private var _mcThumb:MovieClip;
00016         private var _mcJpeg:MovieClip;
00017         public var strThumbUrl:String = "";
00018         private var _jpegLoader:MovieClipLoader;        
00019         private var _bAbortFlag:Boolean = true;
00020         
00021         //class constructor
00022         public function ProgressBarThumb(){
00023                 
00024                 
00025                 this._mcCanvas = this.createEmptyMovieClip("mcCanvas",1);
00026                 this._mcCanvas._y = -5000;
00027                 //this.mcProgressBar._xscale = 0;
00028                 //this.mcProgressBarOutline.swapDepths(12);
00029                 //this.mcProgressBar.swapDepths(11);
00030                 this._mcCanvas._mcJpeg = this._mcCanvas.createEmptyMovieClip("mcJpeg",1);
00031                 this._jpegLoader = new MovieClipLoader();
00032                 this._jpegLoader.addListener(this);
00033                 
00034         }
00035         
00036         public function progressBar(amount:Number){
00037                 //this.mcProgressBar._xscale = amount;
00038         }
00039         
00040         public function initLoader(url:String):Void{
00041                 this.strThumbUrl = url;
00042                 
00043         }
00044         
00045         public function loadThumb(url:String){
00046                 this._bAbortFlag = false;
00047                 this.strThumbUrl = url;
00048                 this._jpegLoader.loadClip(url,this._mcCanvas._mcJpeg);
00049         }
00050         
00051         public function hideLoader():Void{
00052                 this._bAbortFlag = true;
00053                 this.clear();
00054                 this._mcCanvas._y = -5000;
00055         }
00056         
00057         public function showLoader():Void{
00058                 this._mcCanvas._y = 0;
00059         }
00060         
00061         public function abortLoad():Void{
00062                 this._bAbortFlag = true;
00063                 this._mcCanvas._y = -5000;
00064         }
00065         
00066         //called when loading of MediaClip starts
00067         public function onLoadProgress (target:MovieClip,bytesLoaded:Number,bytesTotal:Number):Void {
00068                 if(this._bAbortFlag)
00069                         this._jpegLoader.unloadClip(this._mcCanvas._mcJpeg);
00070         }
00071         
00072         //function called when jpeg load is completed
00073         public function onLoadInit (target:MovieClip):Void{
00074                         if(!this._bAbortFlag){
00075                                 //set thumb border
00076                                 this.setBorder("outline");
00077                                 //position progress bar
00078                                 //this.mcProgressBar._x = this.mcProgressBarOutline._x = (this._mcCanvas._mcJpeg._width/2) - (this.mcProgressBarOutline._width/2);
00079                                 //this.mcProgressBar._y = this.mcProgressBarOutline._y = this._mcCanvas._mcJpeg._height + 5;
00080                         }
00081                 
00082         }
00083 
00084         //function to draw colored border around thumbnail
00085         public function setBorder(strState) {
00086                 switch (strState) {
00087                         case "outline":
00088                                 this.clear();
00089                                 //draw a 1 px border around thumbnail
00090                                 //we use a fill here because Player 7 does not support square-off line ends
00091                                 this.beginFill(0xd6dde6);
00092                                 this.moveTo(-1,-1);
00093                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,-1);
00094                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,0);
00095                                 this.lineTo(-1,0);
00096                                 this.lineTo(-1,-1);
00097                                 this.endFill();
00098                                 this.beginFill(0xd6dde6);
00099                                 this.moveTo(this._mcCanvas._mcJpeg._width+1,-1);
00100                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,this._mcCanvas._mcJpeg._height+1);
00101                                 this.lineTo(this._mcCanvas._mcJpeg._width,this._mcCanvas._mcJpeg._height+1);
00102                                 this.lineTo(this._mcCanvas._mcJpeg._width,-1);
00103                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,-1);
00104                                 this.endFill();
00105                                 this.beginFill(0xd6dde6);
00106                                 this.moveTo(-1,-1);
00107                                 this.lineTo(0,-1);
00108                                 this.lineTo(0,this._mcCanvas._mcJpeg._height+1);
00109                                 this.lineTo(-1,this._mcCanvas._mcJpeg._height+1);
00110                                 this.lineTo(-1,-1);
00111                                 this.endFill();
00112                                 this.beginFill(0xd6dde6);
00113                                 this.moveTo(-1,this._mcCanvas._mcJpeg._height);
00114                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,this._mcCanvas._mcJpeg._height);
00115                                 this.lineTo(this._mcCanvas._mcJpeg._width+1,this._mcCanvas._mcJpeg._height+1);
00116                                 this.lineTo(-1,this._mcCanvas._mcJpeg._height+1);
00117                                 this.lineTo(-1,this._mcCanvas._mcJpeg._height);
00118                                 this.endFill();
00119                                 break;
00120                         case "over":
00121                                 //draw a 1 px border around thumbnail
00122                                 this.beginFill(0x7890AC);
00123                                 this.moveTo(0,0);
00124                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,0);
00125                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,1);
00126                                 this.lineTo(0,1);
00127                                 this.lineTo(0,0);
00128                                 this.endFill();
00129                                 this.beginFill(0x7890AC);
00130                                 this.moveTo(this._mcCanvas._mcJpeg._width+6,0);
00131                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,this._mcCanvas._mcJpeg._height+6);
00132                                 this.lineTo(this._mcCanvas._mcJpeg._width+5,this._mcCanvas._mcJpeg._height+6);
00133                                 this.lineTo(this._mcCanvas._mcJpeg._width+5,0);
00134                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,0);
00135                                 this.endFill();
00136                                 this.beginFill(0x7890AC);
00137                                 this.moveTo(0,0);
00138                                 this.lineTo(1,0);
00139                                 this.lineTo(1,this._mcCanvas._mcJpeg._height+6);
00140                                 this.lineTo(0,this._mcCanvas._mcJpeg._height+6);
00141                                 this.lineTo(0,0);
00142                                 this.endFill();
00143                                 this.beginFill(0x7890AC);
00144                                 this.moveTo(0,this._mcCanvas._mcJpeg._height+5);
00145                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,this._mcCanvas._mcJpeg._height+5);
00146                                 this.lineTo(this._mcCanvas._mcJpeg._width+6,this._mcCanvas._mcJpeg._height+6);
00147                                 this.lineTo(0,this._mcCanvas._mcJpeg._height+6);
00148                                 this.lineTo(0,this._mcCanvas._mcJpeg._height+5);
00149                                 this.endFill();
00150                                 break;
00151                 }
00152         }
00153 
00154 }

Copyright © 2006 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.