00001
00002
00003
00004
00005
00006
00007
00008 import mx.transitions.*;
00009 import mx.xpath.XPathAPI;
00010 import amg.*;
00011
00012 class amg.ImageClip extends MovieClip {
00013
00014 private var _xmlImgNode:XMLNode;
00015 public var strUID:String;
00016 private var _strCurrImgRendition:String;
00017 private var _strCurrMediaUrl:String;
00018 public var strThumbUrl:String;
00019 private var _strBaseRefUrl:String = "";
00020 private var _strTitle:String = "";
00021 private var _strCaption:String = "";
00022 private var _aRenditions:Array;
00023 private var _mcPhotoFile:MovieClip;
00024 private var _mcPhotoFrame:MovieClip;
00025 private var _jpegLoader:MovieClipLoader;
00026 private var _smartLoaderCallback:MovieClip;
00027 private var _bAbortFlag:Boolean = false;
00028 private var _iFrameDepth:Number = 10;
00029 private var _iPhotoDepth:Number = 1;
00030 public var iPercentLoaded:Number = 0;
00031 public var _iBorderColor:Number = 0xffffff;
00032 private var _iBorderAlpha:Number = 100;
00033 private var _iBorderWidth:Number = 0;
00034 private var _bBlankObj:Boolean = false;
00035
00036
00037 public var bDropShadows:Boolean = true;
00038 private var _mcThumbBorderBottom:MovieClip;
00039 private var _mcThumbBorderRight:MovieClip;
00040 private var _mcThumbBorderCapTop:MovieClip;
00041 private var _mcThumbBorderCapL:MovieClip;
00042 private var _mcThumbBorderCapR:MovieClip;
00043
00044
00045 public function ImageClip() {
00046 this._aRenditions = new Array();
00047 }
00048
00049 public function initClip(imgNode:XMLNode,borderWidth:Number, borderColor:Number, borderAlpha:Number,dropShadows:Boolean,baseRefUrl:String) {
00050 this._xmlImgNode = imgNode;
00051 this.strUID = XPathAPI.selectSingleNode(imgNode,"/item/imageId").attributes.image;
00052 this._strTitle = XPathAPI.selectSingleNode(imgNode,"/item/title");
00053 this._strCaption = XPathAPI.selectSingleNode(imgNode,"/item/description");
00054 this._aRenditions = XPathAPI.selectNodeList(imgNode,"/item/renditions/rendition");
00055 this._iBorderWidth = borderWidth;
00056 this._iBorderColor = borderColor;
00057 this._iBorderAlpha = borderAlpha;
00058 this.bDropShadows = dropShadows;
00059 this._strBaseRefUrl = baseRefUrl;
00060
00061 for(var i:Number = 0;i<this._aRenditions.length;i++){
00062 if(this._aRenditions[i].attributes.size == "thumb"){
00063 this.strThumbUrl = this._aRenditions[i].attributes.src;
00064 }
00065 else if(this._aRenditions[i].attributes.type == "blankObj"){
00066 trace("here");
00067 this._bBlankObj = true;
00068 }
00069 }
00070
00071 }
00072
00073 public function setImageUrls(imgNode:XMLNode){
00074 this._xmlImgNode = imgNode;
00075 this.strUID = XPathAPI.selectSingleNode(imgNode,"/item/imageId").attributes.image;
00076 this._strTitle = XPathAPI.selectSingleNode(imgNode,"/item/title");
00077 this._strCaption = XPathAPI.selectSingleNode(imgNode,"/item/description");
00078 this._aRenditions = XPathAPI.selectNodeList(imgNode,"/item/renditions/rendition");
00079
00080 }
00081
00082
00083 public function smartLoadMedia(smartLoader:MovieClip,currImageRendition:String):Void {
00084
00085 this._bAbortFlag = false;
00086
00087 this._mcPhotoFrame = this.createEmptyMovieClip("frame", _iFrameDepth);
00088 this._mcPhotoFile = this._mcPhotoFrame.createEmptyMovieClip("photo", _iPhotoDepth);
00089 this._mcPhotoFile._x = this._mcPhotoFile._y = this._iBorderWidth;
00090
00091
00092 this._strCurrImgRendition = currImageRendition;
00093 for(var i:Number = 0;i<this._aRenditions.length;i++){
00094 if(this._aRenditions[i].attributes.size == currImageRendition){
00095 this._strCurrMediaUrl = this._aRenditions[i].attributes.src;
00096 break;
00097 }
00098 }
00099
00100
00101 this._x = -10000;
00102 this._y = -10000;
00103
00104 _smartLoaderCallback = smartLoader;
00105
00106 if( _root.PreviewInLightroom == 'true' ) {
00107 this._jpegLoader = new LightroomMovieClipLoader();
00108 } else {
00109 this._jpegLoader = new MovieClipLoader();
00110 }
00111
00112 _jpegLoader.addListener(this);
00113
00114 this._jpegLoader.loadClip(this._strBaseRefUrl+this._strCurrMediaUrl, this._mcPhotoFile);
00115
00116 }
00117
00118 public function abortLoad():Void {
00119 this._bAbortFlag = true;
00120 }
00121
00122
00123
00124 public function onLoadProgress(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
00125 if (this._bAbortFlag) {
00126 this._jpegLoader.unloadClip(this._mcPhotoFile);
00127 this.iPercentLoaded = 0;
00128 }
00129 this.iPercentLoaded = (Math.floor(bytesLoaded)/Math.floor(bytesTotal))*100;
00130 }
00131
00132 public function onLoadInit(target:MovieClip):Void {
00133 if (this._bAbortFlag) {
00134 this.iPercentLoaded = 0;
00135 }
00136 else {
00137 this.iPercentLoaded = 100;
00138 this.setBorder();
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 _smartLoaderCallback.smartLoader();
00150 }
00151 }
00152 public function moveMedia(xpos:Number, ypos:Number):Void {
00153 this._x = xpos;
00154 this._y = ypos;
00155 }
00156
00157 public function scaleMedia(scalar:Number):Void {
00158 this._xscale = this._yscale = scalar;
00159 }
00160
00161 public function transitionMedia(xpos:Number, ypos:Number, transitionType:String, dir:String, dur:Number):Void {
00162
00163 var whichDir:Number;
00164
00165 switch (dir) {
00166 case "in" :
00167 this._x = xpos;
00168 this._y = ypos;
00169 whichDir = 0;
00170 break;
00171 case "out" :
00172 whichDir = 1;
00173 break;
00174 }
00175
00176 switch (transitionType) {
00177 case "blinds" :
00178 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Blinds, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00179 break;
00180 case "fade" :
00181 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Fade, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00182 break;
00183 case "fly" :
00184 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Fly, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00185 break;
00186 case "iris" :
00187 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Iris, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00188 break;
00189 case "photo" :
00190 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Photo, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00191 break;
00192 case "pixDissolve" :
00193 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.PixelDissolve, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00194 break;
00195 case "rotate" :
00196 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Rotate, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00197 break;
00198 case "squeeze" :
00199 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Squeeze, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00200 break;
00201 case "wipe" :
00202 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Wipe, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, startPoint:8});
00203 break;
00204 case "zoom" :
00205 TransitionManager.start(this._mcPhotoFrame, {type:mx.transitions.Zoom, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00206 break;
00207 case "keyhole" :
00208 TransitionManager.start(this._mcPhotoFrame, {type:amg.transitions.KeyHole, direction:whichDir, duration:dur, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});
00209 break;
00210 case "cut" :
00211 if(dir == "out")
00212 this._x = -10000;
00213 break;
00214 }
00215 }
00216
00217 public function setBorder():Void {
00218
00219 this.clear();
00220 this._mcPhotoFrame.clear();
00221
00222 this._mcThumbBorderCapTop = this._mcPhotoFrame.attachMovie("mcThumbBorderCapTop","topcap",15);
00223 this._mcThumbBorderRight = this._mcPhotoFrame.attachMovie("mcThumbBorderRight","right_border",14);
00224 this._mcThumbBorderBottom = this._mcPhotoFrame.attachMovie("mcThumbBorderBottom","bot_border",13);
00225 this._mcThumbBorderCapL = this._mcPhotoFrame.attachMovie("mcThumbBorderCapL","leftcap",12);
00226 this._mcThumbBorderCapR = this._mcPhotoFrame.attachMovie("mcThumbBorderCapR","rightcap",11);
00227
00228
00229 this._mcPhotoFrame.beginFill(this._iBorderColor, _iBorderAlpha);
00230 this._mcPhotoFrame.moveTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y);
00231 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y);
00232 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y-this._iBorderWidth);
00233 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y-this._iBorderWidth);
00234 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y);
00235 this._mcPhotoFrame.endFill();
00236
00237 this._mcPhotoFrame.beginFill(this._iBorderColor, _iBorderAlpha);
00238 this._mcPhotoFrame.moveTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height);
00239 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height);
00240 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height+this._iBorderWidth);
00241 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height+this._iBorderWidth);
00242 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height);
00243 this._mcPhotoFrame.endFill();
00244
00245
00246 this._mcPhotoFrame.beginFill(this._iBorderColor, _iBorderAlpha);
00247 this._mcPhotoFrame.moveTo(this._mcPhotoFile._x+this._mcPhotoFile._width, this._mcPhotoFile._y);
00248 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y);
00249 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height);
00250 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width, this._mcPhotoFile._y+this._mcPhotoFile._height);
00251 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x+this._mcPhotoFile._width, this._mcPhotoFile._y);
00252 this._mcPhotoFrame.endFill();
00253
00254
00255 this._mcPhotoFrame.beginFill(this._iBorderColor, _iBorderAlpha);
00256 this._mcPhotoFrame.moveTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y);
00257 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x, this._mcPhotoFile._y);
00258 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x, this._mcPhotoFile._y+this._mcPhotoFile._height);
00259 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y+this._mcPhotoFile._height);
00260 this._mcPhotoFrame.lineTo(this._mcPhotoFile._x-this._iBorderWidth, this._mcPhotoFile._y);
00261 this._mcPhotoFrame.endFill();
00262
00263
00264
00265
00266
00267
00268 if(bDropShadows){
00269 this._mcThumbBorderCapTop._visible = true;
00270 this._mcThumbBorderRight._visible = true;
00271 this._mcThumbBorderBottom._visible = true;
00272 this._mcThumbBorderCapL._visible = true;
00273 this._mcThumbBorderCapR._visible = true;
00274
00275 var tWidth:Number = this._mcPhotoFile._width+(2*this._iBorderWidth);
00276 this._mcThumbBorderCapL._x = this._mcPhotoFile._x-this._iBorderWidth;
00277 this._mcThumbBorderBottom._x = this._mcThumbBorderCapL._x + this._mcThumbBorderCapL._width;
00278 this._mcThumbBorderBottom._y = this._mcThumbBorderCapL._y = this._mcThumbBorderCapR._y = this._mcPhotoFile._height+this._mcPhotoFile._y+this._iBorderWidth;
00279 this._mcThumbBorderBottom._width = tWidth - this._mcThumbBorderCapL._width;
00280 this._mcThumbBorderCapR._x = this._mcThumbBorderBottom._x + this._mcThumbBorderBottom._width;
00281
00282
00283 this._mcThumbBorderCapTop._x = this._mcThumbBorderRight._x = this._mcPhotoFile._x+this._mcPhotoFile._width+this._iBorderWidth;
00284 this._mcThumbBorderCapTop._y = this._mcPhotoFile._y - this._iBorderWidth;
00285 this._mcThumbBorderRight._y = this._mcPhotoFile._y - this._iBorderWidth + this._mcThumbBorderCapTop._height;
00286 this._mcThumbBorderRight._height = this._mcPhotoFile._height + (this._iBorderWidth*2) - this._mcThumbBorderCapR._height;
00287 }
00288 else {
00289 this._mcThumbBorderCapTop._visible = false;
00290 this._mcThumbBorderRight._visible = false;
00291 this._mcThumbBorderBottom._visible = false;
00292 this._mcThumbBorderCapL._visible = false;
00293 this._mcThumbBorderCapR._visible = false;
00294 }
00295
00296
00297
00298
00299 }
00300
00301 public function get x():Number {
00302 return this._mcPhotoFile._x;
00303 }
00304 public function set x(newxpos:Number):Void {
00305 this._mcPhotoFile._x = newxpos;
00306 }
00307 public function get y():Number {
00308 return this._mcPhotoFile._y;
00309 }
00310 public function set y(newypos:Number):Void {
00311 this._mcPhotoFile._y = newypos;
00312 }
00313 public function get width():Number {
00314 var w:Number = this._mcPhotoFile._width + (this._iBorderWidth*2);
00315 if(this.bDropShadows)
00316 w += 4;
00317 return w;
00318 }
00319 public function get height():Number {
00320 var h:Number = this._mcPhotoFile._height + (this._iBorderWidth*2);
00321 if(this.bDropShadows)
00322 h += 4;
00323 return h;
00324 }
00325 }
00326