00001
00002
00003
00004
00005
00006
00007
00008 import amg.*;
00009 import flash.filters.DropShadowFilter;
00010 class amg.ThumbClip extends MovieClip {
00011
00012 private var _iWidth:Number;
00013 private var _iHeight:Number;
00014
00015 private var _iIndexID:Number;
00016 private var _strThumbUrl:String;
00017 private var _mcJpeg:MovieClip;
00018 private var _mcActiveArrow:MovieClip;
00019 private var _smartLoaderCallback:MovieClip;
00020 private var _bBlankObj:Boolean = false;
00021
00022 public var bDropShadows:Boolean = true;
00023 private var _mcThumbBorderBottom:MovieClip;
00024 private var _mcThumbBorderRight:MovieClip;
00025 private var _mcThumbBorderCapTop:MovieClip;
00026 private var _mcThumbBorderCapL:MovieClip;
00027 private var _mcThumbBorderCapR:MovieClip;
00028
00029 private var _iBorderWidth:Number = 3;
00030 private var _iBorderColor:Number = 0xffffff;
00031 private var _iBorderAlpha:Number = 100;
00032 private var _iHoverColor:Number = 0x0000ff;
00033 private var _iHoverAlpha:Number = 100;
00034 private var _iActiveColor:Number = 0xff0000;
00035 private var _iActiveAlpha:Number = 100;
00036 private var _jpegLoader:MovieClipLoader;
00037 public var bActive:Boolean;
00038 public var strLoaded:String = "false";
00039 public var bLastToLoad:Boolean = false;
00040 private var _iMaxThumbWidth:Number = 72;
00041 private var _iMaxThumbHeight:Number = 54;
00042
00043 public function ThumbClip() {
00044
00045 this.onPress = thumbClick;
00046 this.onRollOver = overThumb;
00047 this.onRollOut = offThumb;
00048
00049 if( _root.PreviewInLightroom == 'true' ) {
00050 this._jpegLoader = new LightroomMovieClipLoader();
00051 } else {
00052 this._jpegLoader = new MovieClipLoader();
00053 }
00054 _jpegLoader.addListener(this);
00055 }
00056 public function initClip(id:Number, url:String, maxWidth, maxHeight, borderColor:Number, borderAlpha:Number, borderWidth:Number, hoverColor:Number, hoverAlpha:Number, activeColor:Number, activeAlpha:Number, dropShadows:Boolean):Void {
00057
00058 this.bDropShadows = dropShadows;
00059
00060 this._iWidth = maxWidth+(2*borderWidth);
00061 this._iHeight = maxHeight+(2*borderWidth);
00062
00063 this._iMaxThumbWidth = maxWidth;
00064 this._iMaxThumbHeight = maxHeight;
00065 this._iBorderWidth = borderWidth;
00066
00067 this._mcJpeg = this.createEmptyMovieClip("jpeg", this.getNextHighestDepth());
00068 this._strThumbUrl = url;
00069
00070 this._iIndexID = id;
00071
00072 this._iBorderColor = borderColor;
00073 this._iBorderAlpha = borderAlpha;
00074 this._iBorderWidth = borderWidth;
00075 this._iHoverColor = hoverColor;
00076 this._iHoverAlpha = hoverAlpha;
00077 this._iActiveColor = activeColor;
00078 this._iActiveAlpha = activeAlpha;
00079
00080 this._mcActiveArrow = this.attachMovie("mcActiveArrow", "activeArrow", 30, {_visible:false});
00081 this._mcActiveArrow._x = -4;
00082 this._mcActiveArrow._y = 20;
00083 setTint(this._mcActiveArrow, activeColor, activeAlpha);
00084 }
00085 public function loadThumb(smartLoader:MovieClip):Void {
00086
00087 this._jpegLoader.loadClip(_strThumbUrl, this._mcJpeg);
00088
00089 _smartLoaderCallback = smartLoader;
00090 }
00091
00092
00093 public function onLoadInit(target:MovieClip):Void {
00094 this.strLoaded = "loaded";
00095 if (bLastToLoad) {
00096 _parent.thumbLoadingDone();
00097 bLastToLoad = false;
00098 }
00099
00100 this._mcJpeg._x = Math.floor((this._iWidth-this._mcJpeg._width)/2);
00101 this._mcJpeg._y = Math.floor((this._iHeight-this._mcJpeg._height)/2);
00102
00103 this.setBorder("plain");
00104 if (this.bActive) {
00105 this.setCurrent(true);
00106 }
00107
00108 this._mcJpeg._x = Math.floor((this._iWidth-this._mcJpeg._width)/2);
00109 this._mcJpeg._y = Math.floor((this._iHeight-this._mcJpeg._height)/2);
00110
00111 _smartLoaderCallback.smartLoader();
00112 }
00113 public function onLoadError(target:MovieClip):Void {
00114 trace("ERROR");
00115 }
00116
00117 private function thumbClick():Void {
00118 _root.gallery.dispatchEvent("thumbClick", _iIndexID);
00119 }
00120
00121 private function overThumb():Void {
00122 this.setBorder("over");
00123 }
00124
00125 private function offThumb():Void {
00126 if (this.bActive) {
00127 this.setBorder("active");
00128 } else {
00129 this.setBorder("plain");
00130 }
00131 }
00132 public function setCurrent(current:Boolean):Void {
00133 if (current) {
00134 this.bActive = true;
00135 this._mcActiveArrow._visible = true;
00136 this.setBorder("active");
00137 } else {
00138 this.bActive = false;
00139 this._mcActiveArrow._visible = false;
00140 this.setBorder("plain");
00141 }
00142 }
00143
00144
00145 public function setBorder(strState:String):Void {
00146
00147
00148 if (this.strLoaded != "loaded") {
00149 return;
00150 }
00151 switch (strState) {
00152 case "plain" :
00153 this.clear();
00154
00155 this.beginFill(this._iBorderColor, this._iBorderAlpha);
00156 this.moveTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00157 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00158 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00159 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00160 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00161 this.endFill();
00162 break;
00163 case "active" :
00164
00165
00166 this.beginFill(this._iActiveColor, this._iActiveAlpha);
00167 this.moveTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00168 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00169 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00170 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00171 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00172 this.endFill();
00173
00174 this.beginFill(this._iActiveColor, this._iActiveAlpha);
00175 this.moveTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00176 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00177 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth-1, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00178 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth-1, this._mcJpeg._y-this._iBorderWidth);
00179 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00180 this.endFill();
00181
00182 this.beginFill(this._iActiveColor, this._iActiveAlpha);
00183 this.moveTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._y-this._iBorderWidth);
00184 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00185 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00186 this.lineTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00187 this.lineTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._y-this._iBorderWidth);
00188 this.endFill();
00189
00190 this.beginFill(this._iActiveColor, this._iActiveAlpha);
00191 this.moveTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00192 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00193 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00194 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00195 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00196 this.endFill();
00197
00198 this.setTint(this._mcActiveArrow, this._iActiveColor, this._iActiveAlpha);
00199 this._mcActiveArrow._x = this._mcJpeg._x-this._iBorderWidth-4;
00200 break;
00201 case "over" :
00202
00203
00204 this.beginFill(this._iHoverColor, _iHoverAlpha);
00205 this.moveTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00206 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00207 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00208 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00209 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth+1);
00210 this.endFill();
00211
00212 this.beginFill(this._iHoverColor, _iHoverAlpha);
00213 this.moveTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00214 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00215 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth-1, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00216 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth-1, this._mcJpeg._y-this._iBorderWidth);
00217 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00218 this.endFill();
00219
00220 this.beginFill(this._iHoverColor, _iHoverAlpha);
00221 this.moveTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._y-this._iBorderWidth);
00222 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._y-this._iBorderWidth);
00223 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00224 this.lineTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00225 this.lineTo(this._mcJpeg._x-this._iBorderWidth+1, this._mcJpeg._y-this._iBorderWidth);
00226 this.endFill();
00227
00228 this.beginFill(this._iHoverColor, _iHoverAlpha);
00229 this.moveTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00230 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00231 this.lineTo(this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00232 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth);
00233 this.lineTo(this._mcJpeg._x-this._iBorderWidth, this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth-1);
00234 this.endFill();
00235 break;
00236 }
00237
00238
00239
00240
00241 if (this.bDropShadows) {
00242 this._mcThumbBorderCapTop = this.attachMovie("mcThumbBorderCapTop", "topcap", 10);
00243 this._mcThumbBorderRight = this.attachMovie("mcThumbBorderRight", "right_border", 9);
00244 this._mcThumbBorderBottom = this.attachMovie("mcThumbBorderBottom", "bot_border", 8);
00245 this._mcThumbBorderCapL = this.attachMovie("mcThumbBorderCapL", "leftcap", 7);
00246 this._mcThumbBorderCapR = this.attachMovie("mcThumbBorderCapR", "rightcap", 6);
00247 this._mcThumbBorderCapTop._visible = true;
00248 this._mcThumbBorderRight._visible = true;
00249 this._mcThumbBorderBottom._visible = true;
00250 this._mcThumbBorderCapL._visible = true;
00251 this._mcThumbBorderCapR._visible = true;
00252 var tWidth:Number = this._mcJpeg._width+(2*this._iBorderWidth);
00253 var tHeight:Number = this._mcJpeg._height+(2*this._iBorderWidth);
00254
00255 this._mcThumbBorderCapL._x = this._mcJpeg._x-this._iBorderWidth;
00256 this._mcThumbBorderBottom._x = this._mcThumbBorderCapL._x+this._mcThumbBorderCapL._width;
00257 this._mcThumbBorderBottom._y = this._mcThumbBorderCapL._y=this._mcThumbBorderCapR._y=this._mcJpeg._height+this._mcJpeg._y+this._iBorderWidth;
00258 this._mcThumbBorderBottom._width = tWidth-this._mcThumbBorderCapL._width;
00259 this._mcThumbBorderCapR._x = this._mcThumbBorderBottom._x+this._mcThumbBorderBottom._width;
00260
00261 this._mcThumbBorderCapTop._x = this._mcThumbBorderRight._x=this._mcJpeg._width+this._mcJpeg._x+this._iBorderWidth;
00262 this._mcThumbBorderCapTop._y = this._mcJpeg._y-this._iBorderWidth;
00263 this._mcThumbBorderRight._y = this._mcThumbBorderCapTop._y+this._mcThumbBorderCapTop._height;
00264 this._mcThumbBorderRight._height = tHeight-this._mcThumbBorderCapTop._height;
00265 } else {
00266 this._mcThumbBorderCapTop._visible = false;
00267 this._mcThumbBorderRight._visible = false;
00268 this._mcThumbBorderBottom._visible = false;
00269 this._mcThumbBorderCapL._visible = false;
00270 this._mcThumbBorderCapR._visible = false;
00271 }
00272 }
00273
00274
00275
00276
00277
00278 function setTint(clip:MovieClip, colorVal:Number, alphaVal:Number):Void {
00279 var color:Color = new Color(clip);
00280 var oColorTransform:Object = new Object();
00281 oColorTransform.ra = oColorTransform.ga=oColorTransform.ba=0;
00282 oColorTransform.rb = (colorVal >> 16) & 0xFF;
00283 oColorTransform.gb = (colorVal >> 8) & 0xFF;
00284 oColorTransform.bb = colorVal & 0xFF;
00285 oColorTransform.ab = ((alphaVal/100)*255)-255;
00286 color.setTransform(oColorTransform);
00287 }
00288 }