Adobe Systems, Inc.

SlideShow.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 ** SlideShow Control Class 
00007 **
00008 ** This class controls the main media (images and video) display area.
00009 ** It uses an associative array, aMediaClips, as its main datastructure,
00010 ** which is composed of a media clip object and a start time for the slideshow.
00011 ** The class is also setup to resize itself when a container object calls
00012 ** its setHeightWidth() method.  Styling of the window and controls
00013 ** rely upon a stlye xml node being passed in via parseStyleXML()
00014 ********************************************************************/
00015 import mx.xpath.XPathAPI;
00016 import amg.*;
00017 //implements ISmartLoader interface insuring that the smartLoader callback method is present
00018 class amg.SlideShow extends MovieClip {
00019         //member properties
00020         public var strCurrView:String = "slideshow";
00021         private var _strViewMode:String = "galleryDefault";
00022         private var _strCurrImgSize:String = "large";
00023         private var _bFitAtStart:Boolean = false;
00024         private var _strBaseRefUrl:String = "";
00025         private var _strGroupId:String;
00026         private var _iControlWidth:Number;
00027         private var _iControlHeight:Number;
00028         private var ImageCanvas:MovieClip;
00029         private var ImageCanvasMask:MovieClip;
00030         private var _iTabIndex:Number;
00031         private var ScrollBtnLeft:MovieClip;
00032         private var ScrollBtnRight:MovieClip;
00033         private var ScrollBtnUp:MovieClip;
00034         private var ScrollBtnDown:MovieClip;
00035         private var ScrollLineHoriz:MovieClip;
00036         private var ScrollLineVert:MovieClip;
00037         private var ScrollThumbHoriz:MovieClip;
00038         private var ScrollThumbVert:MovieClip;
00039         private var ScrollThumbMarksHoriz:MovieClip;
00040         private var ScrollThumbMarksVert:MovieClip;
00041         private var _iVertScrollDistance:Number = 100;
00042         private var _iHorizScrollDistance:Number = 100;
00043         private var _bVertScrollUsed:Boolean = false;
00044         private var _bHorizScrollUsed:Boolean = false;
00045         private var _iImageCanvasTopSpacer:Number = 6;
00046         private var _iXmlGroupChunkIndex:Number = Number.MAX_VALUE;             //index of first blank media object, if sequential group file chunks
00047         //margin value for preview box layout
00048         private var _iImageCanvasRightSpacer:Number = 6;
00049         //margin value for preview box layout
00050         private var _iImageCanvasScalar:Number;
00051         private var _iImageCanvasWidth:Number;
00052         private var _iImageCanvasHeight:Number;
00053         private var SlideShowBg:MovieClip;
00054         private var SlideShowVCRButtons:MovieClip;
00055         private var ViewSlideshowBtn:MovieClip;
00056         private var ViewGalleryBtn:MovieClip;
00057         private var ViewMapBtn:MovieClip;
00058         private var SlideShowStatus:MovieClip;
00059         private var SlideShowMetaData:MovieClip;
00060         private var ToolTip:MovieClip;
00061         private var _strSlideShowMetaData:String;
00062         private var RenditionProgress:MovieClip;
00063         private var _bDropShadows:Boolean = true;
00064         private var _iDropShadowBorder:Number = 4;
00065         private var _iSlideShowBg:Number;
00066         private var _iSlideShowBgAlpha:Number;
00067         private var _iSlideShowBorder:Number;
00068         private var _iSlideShowBorderAlpha:Number;
00069         private var _iImageBorderWidth:Number;
00070         private var _iImageBorderColor:Number;
00071         private var _iImageBorderAlpha:Number;
00072         private var _iVideoBorderWidth:Number;
00073         private var _iVideoBorderColor:Number;
00074         private var _iVideoBorderAlpha:Number;
00075         private var _bVideoDropShadows:Boolean = true;
00076         private var _iVideoBgColor:Number;
00077         private var _iVideoBgAlpha:Number;
00078         private var _iVideoBtnForeColor:Number;
00079         private var _iVideoBtnForeAlpha:Number;
00080         private var _iVideoBtnBgColor:Number;
00081         private var _iVideoBtnBgAlpha:Number;
00082         private var _iVideoBtnBorderColor:Number;
00083         private var _iVideoBtnBorderAlpha:Number;
00084         public var strTransitionType:String = "fade";
00085         private var _aImageRenditions:Array;
00086         private var _oSmallRendition:Object;
00087         private var _oMedRendition:Object;
00088         private var _oLargeRendition:Object;
00089         public var strImageLoading = "Loading image...";
00090         public var strSizeLoading = "Loading new image size...";
00091         private var _iNextLargerHeight:Number;
00092         public var bFirstRun:Boolean = true;
00093         public var mediaXPos:Number = 0;
00094         public var mediaYPos:Number = 0;
00095         public var mediaWidth:Number;
00096         public var mediaHeight:Number;
00097         private var _strMediaPostionType:String = "auto";
00098         private var _strImageScale:String = "downOnly";
00099         private var _strVideoScale:String = "downOnly";
00100         //tooltip vars
00101         public var SlideshowVCRNextTip:String = "";
00102         public var SlideshowVCRPrevTip:String = "";
00103         public var SlideshowVCRPlayTip:String = "";
00104         public var SlideshowVCRPauseTip:String = "";
00105         public var SlideshowViewGalleryTip:String = "";
00106         public var SlideshowViewSlideshowTip:String = "";
00107         public var SlideshowVideoPlayTip:String = "";
00108         public var SlideshowVideoPauseTip:String = "";
00109         public var SlideshowVideoRewindTip:String = "";
00110         //preview box layout variables
00111         private var _iOrigMaxImgWidth:Number;
00112         private var _iMaxImgWidth:Number;
00113         //used in scaling images to fit window
00114         private var _iOrigMaxImgHeight:Number;
00115         private var _iMaxImgHeight:Number;
00116         //used in scaling images to fit window
00117         private var _iSlideShowMetadataHeight:Number = 40;
00118         //a scalar used to calculate the preview image size
00119         private var _iControlsBottomSpacer:Number = 7;
00120         private var _iControlsSideSpacer:Number = 9;
00121         private var _iControlsHorizSpacer = 5;
00122         private var _iCaptionBottomSpacer = 5;
00123         //slideshow variables
00124         private var _strPlayMode:String;
00125         //string indicating the state of the slidehow
00126         private var _iStartSlide:Number = 0;
00127         //index of first photo for slideshow
00128         private var _iStartTime:Number = 0;
00129         //beginning time for slideshow
00130         private var _iNextClip:Number = 0;
00131         //index of the next photo to display
00132         private var _iCurrentClip:Number = 0;
00133         //index of photo currently being displayed
00134         private var _iCurrentTime:Number = 0;
00135         //the slideshow's current time (stoppable,startable,resetable)
00136         private var _iTimeOffset:Number = 0;
00137         //the offset between the 'real' system time and slideshow time
00138         private var _bTimerRunning:Boolean = false;
00139         //indicates if slide show timer should be running
00140         private var _bAutoLoop:Boolean = true;
00141         //should the slideshow loop
00142         private var _iSlideDuration:Number = 3;
00143         private var _iTransitionDuration:Number = 0.75;
00144         //time that each photo is displayed in slideshow
00145         //current bandwidth image size
00146         public var aMediaClips:Array;
00147         
00148         //smartLoader variables
00149         private var _bSmartLoad:Boolean = true;                                 //should the smartloader be used
00150         private var _iSmartLoaderIndex:Number = 0;                              //starting index for photo preloading
00151         private var _iSmartLoaderCount:Number = 0;                              //number of photos preloaded
00152         private var _strFirstImageLoaded:String =  "none loaded";       //used to indicate of first image is loaded
00153         private var _strLoadingMode:String = "none";                    //what type of media is being loaded
00154         private var _iLoadingClip:Number = -1;                                  //index of currently loading clip
00155         public var bLoadingComplete:Boolean;                                    //is smartloader done
00156         
00157         private var _bSlideshowMetadataTitles = true;
00158         private var _bSlideshowMetadataCaptions = true;
00159         
00160         //class constructor
00161         public function SlideShow() {
00162                 this.SlideShowBg = this.attachMovie("SlideShowBg", "SlideShowBg", this.getNextHighestDepth());
00163                 this.ImageCanvas = this.attachMovie("ImageCanvas", "imageCanvas", this.getNextHighestDepth());
00164                 this.ImageCanvasMask = this.createEmptyMovieClip("imageCanvasMask", this.getNextHighestDepth());
00165                 this.ScrollBtnUp = this.attachMovie("ScrollBtnUp", "ScrollBtnUp", this.getNextHighestDepth(), {_visible:false});
00166                 this.ScrollBtnUp.fieldName = "Slideshow";
00167                 this.ScrollBtnDown = this.attachMovie("ScrollBtnDown", "ScrollBtnDown", this.getNextHighestDepth(), {_visible:false});
00168                 this.ScrollBtnDown.fieldName = "Slideshow";
00169                 this.ScrollBtnRight = this.attachMovie("ScrollBtnRight", "ScrollBtnRight", this.getNextHighestDepth(), {_visible:false});
00170                 this.ScrollBtnRight.fieldName = "Slideshow";
00171                 this.ScrollBtnLeft = this.attachMovie("ScrollBtnLeft", "ScrollBtnLeft", this.getNextHighestDepth(), {_visible:false});
00172                 this.ScrollBtnLeft.fieldName = "Slideshow";
00173                 this.ScrollLineHoriz = this.attachMovie("ScrollLineHoriz", "ScrollLineHoriz", this.getNextHighestDepth(), {_visible:false});
00174                 this.ScrollLineVert = this.attachMovie("ScrollLineVert", "ScrollLineVert", this.getNextHighestDepth());
00175                 this.ScrollThumbHoriz = this.attachMovie("ScrollThumbHoriz", "ScrollThumbHoriz", this.getNextHighestDepth(), {_visible:false});
00176                 this.ScrollThumbHoriz.onPress = scrollThumbHorizDrag;
00177                 this.ScrollThumbHoriz.onRelease = scrollThumbHorizStopDrag;
00178                 this.ScrollThumbHoriz.onReleaseOutside = scrollThumbHorizStopDrag;
00179                 this.ScrollThumbVert = this.attachMovie("ScrollThumbVert", "ScrollThumbVert", this.getNextHighestDepth(), {_visible:false});
00180                 this.ScrollThumbVert.onPress = scrollThumbVertDrag;
00181                 this.ScrollThumbVert.onRelease = scrollThumbVertStopDrag;
00182                 this.ScrollThumbVert.onReleaseOutside = scrollThumbVertStopDrag;
00183                 this.ScrollThumbMarksHoriz = this.attachMovie("ScrollThumbMarksHoriz", "ScrollThumbMarksHoriz", this.getNextHighestDepth(), {_visible:false});
00184                 this.ScrollThumbMarksVert = this.attachMovie("ScrollThumbMarksVert", "ScrollThumbMarksVert", this.getNextHighestDepth(), {_visible:false});
00185                 this.ImageCanvas.setMask(this.ImageCanvasMask);
00186                 this.SlideShowVCRButtons = this.attachMovie("SlideShowVCRButtons", "SlideShowVCRButtons", this.getNextHighestDepth());
00187                 this.SlideShowStatus = this.attachMovie("SlideShowStatus", "SlideShowStatus", this.getNextHighestDepth());
00188 
00189                 this.SlideShowMetaData = this.attachMovie("SlideShowMetadata", "SlideShowMetadata", this.getNextHighestDepth(), {_visible:true});
00190                 this.SlideShowMetaData.tabEnabled = false;
00191                 //view change buttons
00192                 this.ViewSlideshowBtn = this.attachMovie("ViewSlideshowBtn", "ViewSlideshowBtn", this.getNextHighestDepth(), {_visible:false});
00193                 this.ViewGalleryBtn = this.attachMovie("ViewGalleryBtn", "ViewGalleryBtn", this.getNextHighestDepth(), {_visible:false});
00194                 this.ViewMapBtn = this.attachMovie("ViewMapBtn", "ViewMapBtn", this.getNextHighestDepth(), {_visible:false});
00195                 this.RenditionProgress = this.attachMovie("RenditionProgress", "RenditionProgress", this.getNextHighestDepth(), {_visible:false});
00196                 this.ToolTip = this.attachMovie("ToolTip", "toolTip", this.getNextHighestDepth(), {_visible:false});
00197                 
00198         }
00199         //set inital values for class
00200         public function init(transition:String, transDuration:Number, slideDuration:Number, playmode:String, currView:String, viewMode:String, metaDataHeight:Number, mediaPosition:XMLNode, baseRefUrl:String, fitAtStart:Boolean, p_tabIndex:Number):Void {
00201                 this.strCurrView = currView;
00202                 this._strViewMode = viewMode;
00203                 this.strTransitionType = transition;
00204                 this._iTransitionDuration = transDuration;
00205                 this._iSlideDuration = slideDuration;
00206                 this._strPlayMode = playmode;
00207                 this._iSlideShowMetadataHeight = metaDataHeight;
00208                 this._strBaseRefUrl = baseRefUrl;
00209                 this._strMediaPostionType = mediaPosition.attributes.positionType;
00210                 this._strImageScale = mediaPosition.attributes.imageScale;
00211                 if(_strImageScale == "fitToScreen")
00212                         this.RenditionProgress._visible = true;
00213                 this._strVideoScale = mediaPosition.attributes.videoScale;
00214                 this.mediaXPos = parseFloat(mediaPosition.attributes.x);
00215                 this.mediaYPos = parseFloat(mediaPosition.attributes.y);
00216                 this.mediaWidth = parseFloat(mediaPosition.attributes.width);
00217                 this.mediaHeight = parseFloat(mediaPosition.attributes.height);
00218                 this._bFitAtStart = fitAtStart;
00219                 this._iTabIndex = p_tabIndex;
00220                 this.ScrollBtnUp.tabIndex = this._iTabIndex++;
00221                 this.ScrollBtnDown.tabIndex = this._iTabIndex++;
00222                 this.ScrollBtnRight.tabIndex = this._iTabIndex++;
00223                 this.ScrollBtnLeft.tabIndex = this._iTabIndex++;
00224                 this.ViewMapBtn.tabIndex = this._iTabIndex++;
00225                 this.ViewGalleryBtn.tabIndex = this._iTabIndex++;
00226                 this.ViewSlideshowBtn.tabIndex = this._iTabIndex++;
00227                 this.SlideShowVCRButtons.back.tabIndex = this._iTabIndex++;
00228                 this.SlideShowVCRButtons.PausePlay.Play.tabIndex = this._iTabIndex++;
00229                 this.SlideShowVCRButtons.PausePlay.Pause.tabIndex = this._iTabIndex++;
00230                 this.SlideShowVCRButtons.forward.tabIndex = this._iTabIndex++;
00231         }
00232         
00233         public function startView(startSlide:Number, smartLoad:Boolean):Void {
00234                 this.bFirstRun = true;
00235                 this.bLoadingComplete = false;
00236                 this._iSmartLoaderCount = 0;
00237                 //set the smartloader index to the current photo index
00238                 this._iSmartLoaderIndex = startSlide;
00239                 //set next clips index to that of current 
00240                 this._iCurrentClip = this._iNextClip=startSlide;
00241                 this._bSmartLoad = smartLoad;
00242                 if (smartLoad) {
00243                         this.smartLoader();
00244                 } else {
00245                         this.slideshowControl(startSlide);
00246                 }
00247                 //set the current time to the current images start time
00248                 this._iCurrentTime = aMediaClips[startSlide].startTime;
00249                 this.onEnterFrame = this.checkTime;
00250         }
00251         
00252         /*******************************************
00253         ** dispatchEvent
00254         ** 
00255         *******************************************/
00256         public function dispatchEvent(eventName:String, eventValue:Object) {
00257                 if (eventName == "mediaAdvance") {
00258                         this.slideshowControl(eventValue);
00259                         this._parent.dispatchEvent("mediaAdvance", eventValue);
00260                 } else if (eventName == "togglePause") {
00261                         if (_strPlayMode == "playing") {
00262                                 this.slideshowControl("pause");
00263                         } else {
00264                                 this.slideshowControl("play");
00265                         }
00266                 }
00267         }
00268         
00269         public function clearMediaGroup() {
00270                 for (var i:Number = 0; i<this.aMediaClips.length; i++) {
00271                         this.aMediaClips[i].mediaClip.removeMovieClip();
00272                 }
00273         }
00274         public function parseMediaGroup(xmlMediaGroup:XMLNode) {
00275                 //get group id
00276                 this._strGroupId = XPathAPI.selectSingleNode(xmlMediaGroup, "/mediaGroup/groupInfo/groupData").attributes.groupId;
00277                 this.aMediaClips = new Array();
00278                 //get image rendition sizes
00279                 this._aImageRenditions = new Array();
00280                 var imageSizes:Array = XPathAPI.selectNodeList(xmlMediaGroup, "/mediaGroup/sizes/imageSize");
00281                 //build media renditons array
00282                 for (var i:Number = 0; i<imageSizes.length; i++) {
00283                         var size:Object = new Object();
00284                         size.size = imageSizes[i].attributes.size;
00285                         size.maxwidth = parseFloat(imageSizes[i].attributes.maxwidth);
00286                         size.maxheight = parseFloat(imageSizes[i].attributes.maxheight);
00287                         //set my small, medium and large values for auto sizing
00288                         if(size.size == "small")
00289                                 this._oSmallRendition = size;
00290                         else if(size.size == "medium")
00291                                 this._oMedRendition = size;
00292                         else if(size.size == "large")
00293                                 this._oLargeRendition = size;
00294                                 
00295                         if (imageSizes[i].attributes.size == this._strCurrImgSize) {
00296                                 setImageMaxDim(parseFloat(imageSizes[i].attributes.maxwidth), parseFloat(imageSizes[i].attributes.maxheight));
00297                         }
00298                         _aImageRenditions.push(size);
00299                 }
00300                 //get media item nodes
00301                 var mediaItems:Array = XPathAPI.selectNodeList(xmlMediaGroup, "/mediaGroup/media/item");
00302                 var strTotalGallerySize:String = XPathAPI.selectSingleNode(xmlMediaGroup, "/mediaGroup/media").attributes.totalGallerySize;
00303                 
00304                 var strMediaUrl:String;
00305                 //parse out all photo nodes and create mediaClip objects
00306                 for (var i:Number = 0; i<mediaItems.length; i++) {
00307                         //set start tiem for image in slideshow
00308                         _iStartTime = this.aMediaClips.length*_iSlideDuration;
00309                         var xmlMediaType:XMLNode = XPathAPI.selectSingleNode(mediaItems[i], "/item/mediaType");
00310                         if (xmlMediaType.attributes.category == "video") {
00311                                 //create an video clip
00312                                 var oVideoClip:MovieClip = this.ImageCanvas.attachMovie("VideoClip", "vidClip"+aMediaClips.length, aMediaClips.length);
00313                                 oVideoClip.initClip(mediaItems[i], _iVideoBorderWidth, _iVideoBorderColor, _iVideoBorderAlpha, _bVideoDropShadows, _iVideoBgColor, _iVideoBgAlpha, _iVideoBtnForeColor, _iVideoBtnForeAlpha, _iVideoBtnBgColor, _iVideoBtnBgAlpha, _iVideoBtnBorderColor, _iVideoBtnBorderAlpha, _strBaseRefUrl, this._iTabIndex);
00314                                 //add mediaClip and start time to mediaClips array
00315                                 aMediaClips.push({mediaClip:oVideoClip, mediaClipType:"video", startTime:_iStartTime});
00316                         } else if (xmlMediaType.attributes.category == "image") {
00317                                 //create an image clip
00318                                 var oImageClip:MovieClip = this.ImageCanvas.attachMovie("ImageClip", "imgClip"+aMediaClips.length, aMediaClips.length);
00319                                 oImageClip.initClip(mediaItems[i], _iImageBorderWidth, _iImageBorderColor, _iImageBorderAlpha, _bDropShadows, _strBaseRefUrl);
00320                                 
00321                                         
00322                                 //add imageClip and start time to imageClips array
00323                                 aMediaClips.push({mediaClip:oImageClip, mediaClipType:"image", startTime:_iStartTime});
00324                         }
00325                 }
00326                 
00327                 _iXmlGroupChunkIndex = aMediaClips.length;
00328                 
00329                 if(strTotalGallerySize){
00330                         var totalGallerySize:Number = parseInt(strTotalGallerySize);
00331                         //check if this group represents a subset of the load group chunk preview functionality
00332                         if(totalGallerySize > mediaItems.length){
00333                                 var numBlanks:Number = totalGallerySize - mediaItems.length;
00334                                 for(var j:Number = 0;j<numBlanks;j++){
00335                                         _iStartTime = this.aMediaClips.length*_iSlideDuration;
00336                                         var xmlMediaType:XMLNode = createBlankMediaNode();
00337                                         var oImageClip:MovieClip = this.ImageCanvas.attachMovie("ImageClip", "imgClip"+aMediaClips.length, aMediaClips.length);
00338                                         oImageClip._bBlankObj = true;
00339                                         aMediaClips.push({mediaClip:oImageClip, mediaClipType:"image", startTime:_iStartTime});
00340                                 }
00341                         }
00342                 }
00343                 
00344                 //application is ready to process more images
00345                 _root.readyToProcessChunk = true;
00346                 
00347         }
00348         
00349         /************************************************************************
00350         ** createBlankMediaNode
00351         ***********************************************************************/
00352         private function createBlankMediaNode():XMLNode{
00353                 var blankXML:XML = new XML();
00354                 var itemNode:XMLNode = blankXML.createElement("item");
00355                 var titleNode:XMLNode = blankXML.createElement("title");
00356                 var descriptionNode:XMLNode = blankXML.createElement("description");
00357                 var metadataNode:XMLNode = blankXML.createElement("metadata");
00358                 var photographerNode:XMLNode = blankXML.createElement("photographer");
00359                 var copyrightNode:XMLNode = blankXML.createElement("copyright");
00360                 var imageIdNode:XMLNode = blankXML.createElement("imageId");
00361                 imageIdNode.attributes.image = "";
00362                 imageIdNode.attributes.dbtype = "";
00363                 imageIdNode.attributes.dbname = "";
00364                 var mediaTypeNode:XMLNode = blankXML.createElement("mediaType");
00365                 mediaTypeNode.attributes.category = "image";
00366                 mediaTypeNode.attributes.format = "jpeg";
00367                 var renditionsNode:XMLNode = blankXML.createElement("renditions");
00368                 var renditionNode1:XMLNode = blankXML.createElement("rendition");
00369                 renditionNode1.attributes.size = "thumb";
00370                 renditionNode1.attributes.src = "";
00371                 renditionNode1.attributes.type = "blankObj";
00372                 var renditionNode2:XMLNode = blankXML.createElement("rendition");
00373                 renditionNode2.attributes.size = "small";
00374                 renditionNode2.attributes.src = "";
00375                 renditionNode2.attributes.type = "blankObj";
00376                 var renditionNode3:XMLNode = blankXML.createElement("rendition");
00377                 renditionNode3.attributes.size = "medium";
00378                 renditionNode3.attributes.src = "";
00379                 renditionNode3.attributes.type = "blankObj";
00380                 var renditionNode4:XMLNode = blankXML.createElement("rendition");
00381                 renditionNode4.attributes.size = "large";
00382                 renditionNode4.attributes.src = "";
00383                 renditionNode4.attributes.type = "blankObj";
00384                 
00385                 
00386                 blankXML.appendChild(itemNode);
00387                 itemNode.appendChild(titleNode);
00388                 itemNode.appendChild(descriptionNode);
00389                 itemNode.appendChild(metadataNode);
00390                 itemNode.appendChild(photographerNode);
00391                 itemNode.appendChild(copyrightNode);
00392                 itemNode.appendChild(imageIdNode);
00393                 itemNode.appendChild(mediaTypeNode);
00394                 itemNode.appendChild(renditionsNode);
00395                 renditionsNode.appendChild(renditionNode1);
00396                 renditionsNode.appendChild(renditionNode2);
00397                 renditionsNode.appendChild(renditionNode3);
00398                 renditionsNode.appendChild(renditionNode4);
00399 
00400                 return itemNode;
00401         }
00402         
00403         public function resetSlideDuration(duration:Number) {
00404                 this.slideshowControl("pause");
00405                 this._iSlideDuration = duration;
00406                 for (var i:Number = 0; i<aMediaClips.length; i++) {
00407                         _iStartTime = i*this._iSlideDuration;
00408                         aMediaClips[i].startTime = _iStartTime;
00409                 }
00410                 this._iCurrentTime = aMediaClips[_iCurrentClip].startTime;
00411         }
00412         public function setCurrImgSize(newImgSize:String) {
00413                 this._strCurrImgSize = newImgSize;
00414         }
00415         public function setImageMaxDim(newWidth:Number, newHeight:Number) {
00416                 //add twice the border width to accomodate drawing the border outside the image width
00417                 this._iOrigMaxImgWidth = newWidth;
00418                 this._iOrigMaxImgHeight = newHeight;
00419                 this._iMaxImgWidth = this._iOrigMaxImgWidth+(_iImageBorderWidth*2);
00420                 this._iMaxImgHeight = this._iOrigMaxImgHeight+(_iImageBorderWidth*2);
00421                 if (_bDropShadows) {
00422                         this._iMaxImgWidth += _iDropShadowBorder;
00423                         this._iMaxImgHeight += _iDropShadowBorder;
00424                 }
00425         }
00426         
00427         
00428         /************************************************************************
00429         ** loadGroupXMLChunk
00430         ** Function that allows authoring applications to send a section of the media group xml
00431         ** containing thumb urls to replace blank placeholder objects
00432         ***********************************************************************/
00433         function loadGroupXMLChunk(newMediaGroup:XMLNode){
00434                 var newMediaItems:Array = XPathAPI.selectNodeList(newMediaGroup, "/mediaGroup/media/item");
00435                 
00436                 for(var i:Number=0;i<newMediaItems.length;i++){
00437                         aMediaClips[_iXmlGroupChunkIndex+i].mediaClip.setImageUrls(newMediaItems[i]);
00438                         aMediaClips[_iXmlGroupChunkIndex+i].mediaClip._bBlankObj = false;
00439                 }
00440                 aMediaClips[_iXmlGroupChunkIndex].mediaClip.smartLoadMedia(this, _strCurrImgSize);
00441                 _root.readyToProcessChunk = true;
00442                 _iXmlGroupChunkIndex += i;
00443         }
00444         
00445         
00446         /**************************************************************
00447         ** smartLoader
00448         ** Loads MediaClips in seqential order
00449         ** NOTE: This method passes itself to each MediaClip's load() method.  
00450         ** This callback mechanism allows each clip to finish loading before 
00451         ** the next one starts.
00452         **************************************************************/
00453         public function smartLoader():Void {
00454                 //after the first image is loaded 
00455                 if(this._strFirstImageLoaded == "first loaded"){
00456                         _root.gallery.dispatchEvent("firstImageLoaded");
00457                         this._strFirstImageLoaded = "remainder loading";
00458                 }
00459                 if (aMediaClips[_iSmartLoaderIndex].mediaClipType == "image") {
00460                         //see if the photo at _iSmartLoaderindex is 100% loaded yet
00461                         if (aMediaClips[_iSmartLoaderIndex].mediaClip.iPercentLoaded != 100) {
00462                                 //not loaded, call loading method
00463                                 _root.gallery.writeDebug("slideshow smartload image" + _iSmartLoaderCount);
00464                                 this.aMediaClips[_iSmartLoaderIndex].mediaClip.smartLoadMedia(this, _strCurrImgSize);
00465                                 this._iLoadingClip = _iSmartLoaderIndex;
00466                                 //increment index or flip to 0
00467                                 if (this._iSmartLoaderIndex == this.aMediaClips.length-1) {
00468                                         _iSmartLoaderIndex = 0;
00469                                 } else {
00470                                         this._iSmartLoaderIndex++;
00471                                 }
00472                                 //increment count and set currently loading index
00473                                 this._iSmartLoaderCount++;
00474                                 if(this._strFirstImageLoaded == "none loaded")
00475                                         this._strFirstImageLoaded = "first loaded";
00476                         } else {
00477                                 //check to see if we have loaded all the clips yet
00478                                 if (this._iSmartLoaderCount<aMediaClips.length) {
00479                                         //there are more to load, increment the index and recall function
00480                                         if (this._iSmartLoaderIndex == this.aMediaClips.length-1) {
00481                                                 _iSmartLoaderIndex = 0;
00482                                         } else {
00483                                                 this._iSmartLoaderIndex++;
00484                                         }
00485                                         smartLoader();
00486                                 } else {
00487                                         this.bLoadingComplete = true;
00488                                 }
00489                         }
00490                 } else if (aMediaClips[_iSmartLoaderIndex].mediaClipType == "video") {
00491                         this._iSmartLoaderIndex++;
00492                         this._iSmartLoaderCount++;
00493                         if (this._iSmartLoaderCount<aMediaClips.length) {
00494                                 this.smartLoader();
00495                         } else {
00496                                 this.bLoadingComplete = true;
00497                         }
00498                 }
00499         }
00500         /*******************************************
00501         ** startTimer, stopTimer
00502         ** Flip the timer running flag
00503         *******************************************/
00504         private function startTimer():Void {
00505                 _bTimerRunning = true;
00506         }
00507         private function stopTimer():Void {
00508                 _bTimerRunning = false;
00509         }
00510         /**********************************************************************
00511         ** checkTime
00512         ** Called on this class' enterFrame event (24times/sec)
00513         ** Checks current slideshow time against startTime prop in aMediaClips 
00514         ***********************************************************************/
00515         private function checkTime():Void {
00516                 //check if the slideshow timer is running
00517                 if (_bTimerRunning) {
00518                         //if the timer is running, update the current time
00519                         _iCurrentTime = (getTimer()/1000)-_iTimeOffset;
00520                 } else {
00521                         //if not running, update the time offset
00522                         _iTimeOffset = (getTimer()/1000)-_iCurrentTime;
00523                 }
00524                 //if there is another set of clips
00525                 if (_iNextClip<aMediaClips.length) {
00526                         //is time to show a photo?
00527                         if (_iCurrentTime>=aMediaClips[_iNextClip].startTime) {
00528                                 if (aMediaClips[_iNextClip].mediaClipType == "image") {
00529                                         //see if the jpeg for this mediaClip is 100% downloaded 
00530                                         //_parent.writeDebug("checkTime Loaded: "+aMediaClips[_iNextClip].mediaClip.iPercentLoaded.toString(),"main");
00531                                         if ((aMediaClips[_iNextClip].mediaClip.iPercentLoaded>=100)) {
00532                                                 this.showClip();
00533                                                 this._strLoadingMode = "none";
00534                                                 this.SlideShowStatus.mcProgressBar._alpha = 0;
00535                                                 this.SlideShowStatus.mcProgressBar.mcRedBar._xscale = 0;
00536                                                 this.RenditionProgress._visible = false;
00537                                                 this.RenditionProgress.mcProgressBar.mcRedBar._xscale = 0;
00538                                         } else if ((aMediaClips[_iNextClip].mediaClip.iPercentLoaded<90) && (aMediaClips[_iNextClip].mediaClip.iPercentLoaded>1)) {
00539                                                 //image not loaded 100% yet, stop slideshow timer and show loading message
00540                                                 this._bTimerRunning = false;
00541                                                 if (_strLoadingMode != "photo") {
00542                                                         
00543                                                         //update display
00544                                                         this.SlideShowStatus.SlideShowStatusText.txtSlideNumber.text = (_iNextClip+1)+" / "+aMediaClips.length;
00545                                                         //update progress bar
00546                                                         this.SlideShowStatus.mcProgressBar._alpha = 100;
00547                                                         this.RenditionProgress.mcProgressBar._alpha = 100;
00548                                                         //show progressbarthumb 
00549                                                         this._strLoadingMode = "photo";
00550                                                 }
00551                                                 //update progress bar  
00552                                                 this.SlideShowStatus.mcProgressBar.mcRedBar._xscale = aMediaClips[_iNextClip].mediaClip.iPercentLoaded;
00553                                                 this.RenditionProgress.mcProgressBar.mcRedBar._xscale = aMediaClips[_iNextClip].mediaClip.iPercentLoaded;
00554                                         }
00555                                 } else if (aMediaClips[_iNextClip].mediaClipType == "video") {
00556                                         if (aMediaClips[_iNextClip].mediaClip.iPercentLoaded>=100) {
00557                                                 this.showClip();
00558                                         } else if (aMediaClips[_iNextClip].mediaClip.iPercentLoaded<1) {
00559                                                 aMediaClips[_iNextClip].mediaClip.loadVideo();
00560                                         }
00561                                 }
00562                         }
00563                 } else if ((_bAutoLoop) && (_iCurrentTime>=(aMediaClips[aMediaClips.length-1].startTime+_iSlideDuration))) {
00564                         slideshowControl("play");
00565                 }
00566                 //show _iCurrentTime in dubug window;              
00567                 //if (_parent._bDebugWindow) {
00568                 //_parent.writeDebug(_iCurrentTime.toString(), "time");
00569                 //}
00570         }
00571         private function videoComplete():Void {
00572                 if (this._strPlayMode == "waitingVideo") {
00573                         _strPlayMode = "playing";
00574                         slideshowControl("forward");
00575                 }
00576         }
00577         /**********************************************************************
00578         ** showClip
00579         ** Shows the jpeg image and caption for the current mediaClip object
00580         ***********************************************************************/
00581         private function showClip():Void {
00582                 if ((_iNextClip == _iCurrentClip) && (!bFirstRun)) {
00583                         return;
00584                 }
00585                 bFirstRun = false;
00586                 //determine media scaling based on image canvas size
00587                 var scalar:Number = 1;
00588                 if (this.aMediaClips[this._iNextClip].mediaClip.width>_iImageCanvasWidth) {
00589                         scalar = (_iImageCanvasWidth/this.aMediaClips[this._iNextClip].mediaClip.width);
00590                 }
00591                 if ((this.aMediaClips[this._iNextClip].mediaClip.height*scalar)>_iImageCanvasHeight) {
00592                         scalar = (_iImageCanvasHeight/this.aMediaClips[this._iNextClip].mediaClip.height);
00593                 }
00594                 if (this.aMediaClips[this._iNextClip].mediaClipType == "image") {
00595                         this.aMediaClips[this._iNextClip].mediaClip.scaleMedia(scalar*100);
00596                         var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iNextClip].mediaClip.width*scalar)/2);
00597                         var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iNextClip].mediaClip.height*scalar)/2);
00598                         this.aMediaClips[_iNextClip].mediaClip.moveMedia(newxpos, newypos);
00599                         if (_strPlayMode == "waitingVideo") {
00600                                 this.slideshowControl("waitVideo");
00601                                 _strPlayMode = "playing";
00602                         }
00603                 } else if (this.aMediaClips[this._iNextClip].mediaClipType == "video") {
00604                         this.aMediaClips[_iNextClip].mediaClip.setHeightWidth(_iImageCanvasHeight, _iImageCanvasWidth, this._strVideoScale);
00605                         var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iNextClip].mediaClip.width)/2);
00606                         var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iNextClip].mediaClip.height)/2);
00607                         this.aMediaClips[_iNextClip].mediaClip.moveMedia(newxpos, newypos);
00608                         //if ((_strPlayMode == "playing") || (_strPlayMode == "waitingVideo")) {
00609                                 //this.slideshowControl("waitVideo");
00610                                 this.aMediaClips[_iNextClip].mediaClip.playVideo();
00611                         //}
00612                 }
00613                 this.aMediaClips[_iCurrentClip].mediaClip.transitionMedia(aMediaClips[_iCurrentClip].mediaClip.x, aMediaClips[_iCurrentClip].mediaClip.y, this.strTransitionType, "out", this._iTransitionDuration);
00614                 this.aMediaClips[_iNextClip].mediaClip.transitionMedia(newxpos, newypos, this.strTransitionType, "in", this._iTransitionDuration);
00615                 this._parent.dispatchEvent("setMediaItem", _iNextClip);
00616                 //increment clips counters: next becomes current
00617                 this._iCurrentClip = _iNextClip;
00618                 this._iNextClip++;
00619                 //_parent.writeDebug("showClip: iNextClip "+_iNextClip.toString(),"main");
00620                 //update display text
00621                 //set slideshow metadata text
00622                 var slideshowMetadataText:String = "";
00623                 if (this._bSlideshowMetadataTitles) {
00624                         slideshowMetadataText = aMediaClips[_iCurrentClip].mediaClip._strTitle+"";
00625                 }
00626                 if (this._bSlideshowMetadataCaptions) {
00627                         slideshowMetadataText += aMediaClips[_iCurrentClip].mediaClip._strCaption;
00628                 }
00629                 this.SlideShowMetaData.setTextValue(slideshowMetadataText);
00630                 
00631                 
00632                 this.SlideShowStatus.SlideShowStatusText.txtSlideNumber.text = (_iCurrentClip+1)+" / "+aMediaClips.length;
00633                 this.setHeightWidth(this._iControlHeight, this._iControlWidth);
00634                 //start the timer if slideshow is in play mode
00635                 if (this._strPlayMode == "playing") {
00636                         this.startTimer();
00637                 }
00638         }
00639         /**********************************************************************
00640         ** refreshClip
00641         ** called when live preview needs to change the image border
00642         ***********************************************************************/
00643         private function refreshClip():Void {
00644                 var newxpos:Number = (((this._iImageCanvasScalar*_iMaxImgWidth)/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.width*(this._iImageCanvasScalar))/2))/this._iImageCanvasScalar;
00645                 var newypos:Number = (((this._iImageCanvasScalar*_iMaxImgHeight)/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.height*(this._iImageCanvasScalar))/2))/this._iImageCanvasScalar;
00646                 this.aMediaClips[_iCurrentClip].mediaClip.transitionMedia(aMediaClips[_iCurrentClip].mediaClip.x, aMediaClips[_iCurrentClip].mediaClip.y, "cut", "out", this._iTransitionDuration);
00647                 this.aMediaClips[_iCurrentClip].mediaClip.transitionMedia(newxpos, newypos, "cut", "in", this._iTransitionDuration);
00648         }
00649         /*******************************************
00650         ** slideshowControl
00651         ** Method to control slidshow playback based on
00652         ** the command pause, play, next, etc.
00653         *******************************************/
00654         private function slideshowControl(p_command:Object):Boolean {
00655                 //stop the timer
00656                 stopTimer();
00657                 //determine next set of clips to show based on the argument
00658                 switch (p_command) {
00659                 case "play" :
00660                         if (this.aMediaClips[this._iCurrentClip].mediaClipType == "video") {
00661                                 this.slideshowControl("waitVideo");
00662                                 this.aMediaClips[_iCurrentClip].mediaClip.playVideo();
00663                                 return true;
00664                         }
00665                         //_iTimeOffset = (getTimer()/1000) - _iCurrentTime; 
00666                         _strPlayMode = "playing";
00667                         this.SlideShowVCRButtons.PausePlay.Play._visible = false;
00668                         this.SlideShowVCRButtons.PausePlay.Pause._visible = true;
00669                         if (_iNextClip>(aMediaClips.length-1)) {
00670                                 _iNextClip = 0;
00671                         }
00672                         break;
00673                 case "forward" :
00674                         if (this._strLoadingMode == "thumbs" || this._strLoadingMode == "photo") {
00675                                 _iNextClip++;
00676                         }
00677                         //loop around if end of show    
00678                         if (_iNextClip>(aMediaClips.length-1)) {
00679                                 _iNextClip = 0;
00680                         }
00681                         break;
00682                 case "pause" :
00683                         stopTimer();
00684                         _strPlayMode = "paused";
00685                         this.SlideShowStatus.SlideShowStatusText.txtSlideNumber.text = (_iCurrentClip+1)+" / "+aMediaClips.length;
00686                         this.SlideShowVCRButtons.PausePlay.Play._visible = true;
00687                         this.SlideShowVCRButtons.PausePlay.Pause._visible = false;
00688                         if (this.aMediaClips[this._iCurrentClip].mediaClipType == "video") {
00689                                 this.aMediaClips[_iCurrentClip].mediaClip.pauseVideo();
00690                         }
00691                         return false;
00692                         break;
00693                 case "waitVideo" :
00694                         stopTimer();
00695                         _strPlayMode = "waitingVideo";
00696                         this.SlideShowStatus.SlideShowStatusText.txtSlideNumber.text = (_iCurrentClip+1)+" / "+aMediaClips.length;
00697                         this.SlideShowVCRButtons.PausePlay.Play._visible = false;
00698                         this.SlideShowVCRButtons.PausePlay.Pause._visible = true;
00699                         return false;
00700                         break;
00701                 case "back" :
00702                         //_strPlayMode = "paused";
00703                         if (this._strLoadingMode == "thumbs" || this._strLoadingMode == "photo") {
00704                                 _iNextClip -= 1;
00705                         } else {
00706                                 _iNextClip -= 2;
00707                         }
00708                         
00709                         //loop around if beginning of show; 
00710                         if (_iNextClip<0) {
00711                                 if(!aMediaClips[aMediaClips.length-1].mediaClip._bBlankObj)
00712                                         _iNextClip = aMediaClips.length-1;
00713                                 else {
00714                                         _iNextClip = 1;
00715                                         return true;
00716                                 }
00717                         }
00718                         break;
00719                 default :
00720                         //numerical value
00721                         //pause the slideshow
00722                         if ((p_command.toString() == _iCurrentClip) && (!bFirstRun)) {
00723                                 return true;
00724                         }
00725                         _strPlayMode = "paused";
00726                         this.SlideShowVCRButtons.PausePlay.Play._visible = true;
00727                         //set the clip index to thumb number
00728                         _iNextClip = parseInt(p_command.toString());
00729                         break;
00730                 }
00731                 //the user is requesting a new media item
00732                 //kill the currently loading clip --unless it is the one the user wants to see
00733                 if ((_iNextClip != _iLoadingClip)) {
00734                         if (aMediaClips[_iNextClip].mediaClip.iPercentLoaded != 100) {
00735                                 //kill the curently loading clip
00736                                 aMediaClips[_iLoadingClip].mediaClip.abortLoad();
00737                                 //load next clip
00738                                 this._iSmartLoaderIndex = _iNextClip;
00739                                 smartLoader();
00740                         }
00741                 }
00742                 _iCurrentTime = aMediaClips[_iNextClip].startTime;
00743                 this.SlideShowStatus.SlideShowStatusText.txtSlideNumber.text = (_iNextClip+1)+" / "+aMediaClips.length;
00744                 this._parent.dispatchEvent("setMediaItem", _iNextClip);
00745                 //_parent.writeDebug("ssControl: iNextClip "+_iNextClip.toString(),"main");
00746                 return true;
00747         }
00748         public function playCurrentVideo() {
00749                 this.aMediaClips[_iCurrentClip].mediaClip.playVideo();
00750         }
00751         public function pauseCurrentVideo() {
00752                 this.aMediaClips[_iCurrentClip].mediaClip.pauseVideo();
00753         }
00754         public function rewindCurrentVideo() {
00755                 this.aMediaClips[_iCurrentClip].mediaClip.rewindVideo();
00756         }
00757         public function videoFullSize() {
00758                 this.aMediaClips[_iCurrentClip].mediaClip.videoFullSize();
00759         }
00760         public function changeCurrView(newView:String, newRenditionSize:String) {
00761                 if(this._strCurrImgSize != newRenditionSize){
00762                         this.RenditionProgress.SlideShowStatusText.txtSlideNumber.text = strImageLoading;
00763                         this.RenditionProgress._visible = true;
00764                 }
00765                 //transition current image out, unless it is a video
00766                 //if(this.aMediaClips[_iCurrentClip].mediaType == "
00767                 this.aMediaClips[_iCurrentClip].mediaClip.transitionMedia(aMediaClips[_iCurrentClip].mediaClip.x, aMediaClips[_iCurrentClip].mediaClip.y, "cut", "out", this._iTransitionDuration);
00768                 //set display mode
00769                 this.strCurrView = newView;
00770                 //set image rendition size
00771                 this._strCurrImgSize = newRenditionSize;
00772                 //set max h/w dimensions
00773                 for (var i:Number = 0; i<this._aImageRenditions.length; i++) {
00774                         if (this._aImageRenditions[i].size == newRenditionSize) {
00775                                 setImageMaxDim(this._aImageRenditions[i].maxwidth, this._aImageRenditions[i].maxheight);
00776                                 break;
00777                         }
00778                 }
00779                 //abort currently loading clip
00780                 this.aMediaClips[_iCurrentClip].mediaClip.abortLoad();
00781                 //mark clips as unloaded
00782                 for (i=0; i<this.aMediaClips.length; i++) {
00783                         this.aMediaClips[i].mediaClip.iPercentLoaded = 0;
00784                 }
00785                 //start the slideshow at proper image
00786                 this.startView(this._iCurrentClip, this._bSmartLoad);
00787         }
00788         public function parseStyleXML(styleNode:XMLNode):Void {
00789                 var xmlSlideShowBgFill:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowBgColor");
00790                 var xmlSlideShowBorder:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowBorder");
00791                 var xmlImageBorder:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/images/imageBorder");
00792                 this._iImageBorderWidth = parseFloat(xmlImageBorder.attributes.width);
00793                 this._iImageBorderColor = parseInt("0x"+xmlImageBorder.attributes.color);
00794                 this._iImageBorderAlpha = parseInt("0x"+xmlImageBorder.attributes.alpha);
00795                 var xmlImageDropShadow:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/images/imageDropShadow");
00796                 if (xmlImageDropShadow.attributes.enabled == "true") {
00797                         this._bDropShadows = true;
00798                 } else {
00799                         this._bDropShadows = false;
00800                 }
00801                 var xmlSlideShowMetadata:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowMetadata");
00802                 var xmlSlideShowMetadataField:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowMetadata/metadataField");
00803                 var xmlSlideShowMetadataText:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowMetadata/metadataFieldText");
00804                 var xmlSlideShowCtrlText:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowButtons/slideshowCtrlText");
00805                 var xmlSlideShowCtrlBorder:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowButtons/slideshowBtnBorder");
00806                 var xmlSlideShowCtrlBg:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowButtons/slideshowBtnBackground");
00807                 var xmlSlideShowCtrlFore:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/slideshowButtons/slideshowBtnFore");
00808                 //SlideShow Area
00809                 //set values
00810                 this._iSlideShowBg = parseInt("0x"+xmlSlideShowBgFill.attributes.color);
00811                 this._iSlideShowBgAlpha = parseInt(xmlSlideShowBgFill.attributes.alpha);
00812                 this._iSlideShowBorder = parseInt("0x"+xmlSlideShowBorder.attributes.color);
00813                 this._iSlideShowBorderAlpha = parseInt(xmlSlideShowBorder.attributes.alpha);
00814                 this.SlideShowBg.setColors(0, this._iSlideShowBorder, this._iSlideShowBorderAlpha, this._iSlideShowBg, this._iSlideShowBgAlpha);
00815                 this.SlideShowMetaData._alpha = xmlSlideShowMetadataText.attributes.alpha;
00816                 var txtFont:String = xmlSlideShowMetadataText.attributes.fontFamily;
00817                 var txtColor:String = "#"+xmlSlideShowMetadataText.attributes.color;
00818                 var txtSize:String = xmlSlideShowMetadataText.attributes.size;
00819                 var txtAlign:String = "center";
00820                 if (txtFont == "Myriad Web Pro") {
00821                         this.SlideShowMetaData.txtField.embedFonts = true;
00822                 } else {
00823                         this.SlideShowMetaData.txtField.embedFonts = false;
00824                 }
00825                 var styles:TextField.StyleSheet = new TextField.StyleSheet();
00826                 styles.setStyle("title", {color:txtColor, fontFamily:txtFont, fontSize:txtSize, textAlign:txtAlign, fontWeight:'bold'});
00827                 styles.setStyle("description", {color:txtColor, fontFamily:txtFont, fontSize:txtSize, textAlign:txtAlign, fontWeight:'normal'});
00828                 styles.setStyle("a:link", {color:txtColor});
00829                 styles.setStyle("a:hover", {textDecoration:'underline'});
00830                 this.SlideShowMetaData.txtField.styleSheet = styles;
00831                 if (xmlSlideShowMetadataField.attributes.titles == "true") {
00832                         this._bSlideshowMetadataTitles = true;
00833                 } else {
00834                         this._bSlideshowMetadataTitles = false;
00835                 }
00836                 if (xmlSlideShowMetadataField.attributes.captions == "true") {
00837                         this._bSlideshowMetadataCaptions = true;
00838                 } else {
00839                         this._bSlideshowMetadataCaptions = false;
00840                 }
00841                 //Video Controller
00842                 var xmlVideoCtrlBgColor:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoCtrlBgColor");
00843                 var xmlVideoCtrlBorder:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoCtrlBorder");
00844                 var xmlVideoDropShadow:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoDropShadow");
00845                 var xmlVideoBtnFore:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoCtrlBtnFore");
00846                 var xmlVideoBtnBorder:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoCtrlBtnBorder");
00847                 var xmlVideoBtnBg:XMLNode = XPathAPI.selectSingleNode(styleNode, "/slideshow/videoCtrl/videoCtrlBtnBackground");
00848                 this._iVideoBgColor = parseInt("0x"+xmlVideoCtrlBgColor.attributes.color);
00849                 this._iVideoBgAlpha = parseInt(xmlVideoCtrlBgColor.attributes.alpha);
00850                 this._iVideoBorderWidth = parseFloat(xmlVideoCtrlBorder.attributes.width);
00851                 this._iVideoBorderColor = parseInt("0x"+xmlVideoCtrlBorder.attributes.color);
00852                 this._iVideoBorderAlpha = parseInt(xmlVideoCtrlBorder.attributes.alpha);
00853                 //buttons
00854                 this._iVideoBtnForeColor = parseInt("0x"+xmlVideoBtnFore.attributes.color);
00855                 this._iVideoBtnForeAlpha = parseInt(xmlVideoBtnFore.attributes.alpha);
00856                 this._iVideoBtnBorderColor = parseInt("0x"+xmlVideoBtnBorder.attributes.color);
00857                 this._iVideoBtnBorderAlpha = parseInt(xmlVideoBtnBorder.attributes.alpha);
00858                 this._iVideoBtnBgColor = parseInt("0x"+xmlVideoBtnBg.attributes.color);
00859                 this._iVideoBtnBgAlpha = parseInt(xmlVideoBtnBg.attributes.alpha);
00860                 if (xmlVideoDropShadow.attributes.enabled == "true") {
00861                         this._bVideoDropShadows = true;
00862                 } else {
00863                         this._bVideoDropShadows = false;
00864                 }
00865                 this.setTint(SlideShowStatus.SlideShowStatusText, xmlSlideShowCtrlText.attributes.color, xmlSlideShowCtrlText.attributes.alpha);
00866                 //forward button
00867                 this.setTint(SlideShowVCRButtons.forward.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00868                 this.setTint(SlideShowVCRButtons.forward.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00869                 this.setTint(SlideShowVCRButtons.forward.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00870                 //back button
00871                 this.setTint(SlideShowVCRButtons.back.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00872                 this.setTint(SlideShowVCRButtons.back.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00873                 this.setTint(SlideShowVCRButtons.back.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00874                 //play button
00875                 this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00876                 this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00877                 this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00878                 //pause button
00879                 this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00880                 this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00881                 this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00882                 //toggle view buttons
00883                 this.setTint(ViewSlideshowBtn.ViewIconFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00884                 this.setTint(ViewGalleryBtn.ViewIconFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00885                 this.setTint(ViewSlideshowBtn.ViewIconFill, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00886                 this.setTint(ViewGalleryBtn.ViewIconFill, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00887                 //caption scroll buttons
00888                 this.setTint(this.SlideShowMetaData._btnUp.MetadataScrollBtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00889                 this.setTint(this.SlideShowMetaData._btnDown.MetadataScrollBtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00890                 this.setTint(this.SlideShowMetaData._btnUp.MetadataScrollArrowUp, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00891                 this.setTint(this.SlideShowMetaData._btnDown.MetadataScrollArrowDown, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00892                 //Right Scroll Button
00893                 this.setTint(ScrollBtnRight.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00894                 this.setTint(ScrollBtnRight.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00895                 this.setTint(ScrollBtnRight.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00896                 //Left Scroll Button
00897                 this.setTint(ScrollBtnLeft.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00898                 this.setTint(ScrollBtnLeft.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00899                 this.setTint(ScrollBtnLeft.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00900                 //Up Scroll Button
00901                 this.setTint(ScrollBtnUp.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00902                 this.setTint(ScrollBtnUp.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00903                 this.setTint(ScrollBtnUp.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00904                 //Down Scroll Button
00905                 this.setTint(ScrollBtnDown.BtnFore, xmlSlideShowCtrlFore.attributes.color, xmlSlideShowCtrlFore.attributes.alpha);
00906                 this.setTint(ScrollBtnDown.BtnBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00907                 this.setTint(ScrollBtnDown.BtnBg, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00908                 //ScrollLines
00909                 this.setTint(ScrollLineHoriz.ScrollLineBottom, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00910                 this.setTint(ScrollLineHoriz.ScrollLineTop, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00911                 this.setTint(ScrollLineVert.ScrollLineBottom, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00912                 this.setTint(ScrollLineVert.ScrollLineTop, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00913                 //ScrollThumbs
00914                 this.setTint(ScrollThumbHoriz.ScrollThumbBg.ScrollThumbBgFill, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00915                 this.setTint(ScrollThumbHoriz.ScrollThumbBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00916                 this.setTint(ScrollThumbVert.ScrollThumbBg.ScrollThumbBgFill, xmlSlideShowCtrlBg.attributes.color, xmlSlideShowCtrlBg.attributes.alpha);
00917                 this.setTint(ScrollThumbVert.ScrollThumbBorder, xmlSlideShowCtrlBorder.attributes.color, xmlSlideShowCtrlBorder.attributes.alpha);
00918         }
00919         public function livePreview(whichPart:String, styleNode:XMLNode):Void {
00920                 this.bFirstRun = true;
00921                 switch (whichPart) {
00922                 case "slideshowBorder" :
00923                         this._iSlideShowBorder = parseInt("0x"+styleNode.attributes.color);
00924                         this._iSlideShowBorderAlpha = parseInt(styleNode.attributes.alpha);
00925                         this.SlideShowBg.setColors(0, this._iSlideShowBorder, this._iSlideShowBorderAlpha, this._iSlideShowBg, this._iSlideShowBgAlpha);
00926                         break;
00927                 case "slideshowBgColor" :
00928                         this._iSlideShowBg = parseInt("0x"+styleNode.attributes.color);
00929                         this._iSlideShowBgAlpha = parseInt(styleNode.attributes.alpha);
00930                         this.SlideShowBg.setColors(0, this._iSlideShowBorder, this._iSlideShowBorderAlpha, this._iSlideShowBg, this._iSlideShowBgAlpha);
00931                         break;
00932                 case "metadataField" :
00933                         this._iSlideShowMetadataHeight = parseFloat(styleNode.attributes.height);
00934                         if (styleNode.attributes.titles == "true") {
00935                                 this._bSlideshowMetadataTitles = true;
00936                         } else {
00937                                 this._bSlideshowMetadataTitles = false;
00938                         }
00939                         if (styleNode.attributes.captions == "true") {
00940                                 this._bSlideshowMetadataCaptions = true;
00941                         } else {
00942                                 this._bSlideshowMetadataCaptions = false;
00943                         }
00944                         var slideshowMetadataText:String = "";
00945                         if (this._bSlideshowMetadataTitles) {
00946                                 slideshowMetadataText = aMediaClips[_iCurrentClip].mediaClip._strTitle+"";
00947                         }
00948                         if (this._bSlideshowMetadataCaptions) {
00949                                 slideshowMetadataText += aMediaClips[_iCurrentClip].mediaClip._strCaption;
00950                         }
00951                         this.SlideShowMetaData.setTextValue(slideshowMetadataText);
00952                         break;
00953                 case "metadataFieldText" :
00954                         //automatically set the text field height based on a scalar of 1.5 for 2 lines of text
00955                         this._iSlideShowMetadataHeight = parseFloat(styleNode.attributes.size) * 3;
00956                         this.SlideShowMetaData._alpha = styleNode.attributes.alpha;
00957                         var txtFont:String = styleNode.attributes.fontFamily;
00958                         var txtColor:String = "#"+styleNode.attributes.color;
00959                         var txtSize:String = styleNode.attributes.size;
00960                         var txtAlign:String = "center";
00961                         if (txtFont == "Myriad Web Pro") {
00962                                 this.SlideShowMetaData.txtField.embedFonts = true;
00963                         } else {
00964                                 this.SlideShowMetaData.txtField.embedFonts = false;
00965                         }
00966                         var styles:TextField.StyleSheet = new TextField.StyleSheet();
00967                         styles.setStyle("title", {color:txtColor, fontFamily:txtFont, fontSize:txtSize, textAlign:txtAlign, fontWeight:'bold'});
00968                         styles.setStyle("description", {color:txtColor, fontFamily:txtFont, fontSize:txtSize, textAlign:txtAlign, fontWeight:'normal'});
00969                         styles.setStyle("a:link", {color:txtColor});
00970                         styles.setStyle("a:hover", {textDecoration:'underline'});
00971                         
00972                         this.SlideShowMetaData.txtField.styleSheet = styles;
00973                         
00974                         break;
00975                 case "slideshowCtrlText" :
00976                         this.setTint(SlideShowStatus.SlideShowStatusText, styleNode.attributes.color, styleNode.attributes.alpha);
00977                         break;
00978                 case "slideshowBtnBorder" :
00979                         this.setTint(SlideShowVCRButtons.forward.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00980                         this.setTint(SlideShowVCRButtons.back.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00981                         this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00982                         this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00983                         this.setTint(ViewSlideshowBtn.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00984                         this.setTint(ViewGalleryBtn.BtnBorder, styleNode.attributes.color, styleNode.attributes.alpha);
00985                         break;
00986                 case "slideshowBtnBackground" :
00987                         this.setTint(SlideShowVCRButtons.forward.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00988                         this.setTint(SlideShowVCRButtons.back.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00989                         this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00990                         this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00991                         this.setTint(ViewSlideshowBtn.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00992                         this.setTint(ViewGalleryBtn.BtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00993                         //toggle view buttons
00994                         this.setTint(ViewSlideshowBtn.ViewIconFill, styleNode.attributes.color, styleNode.attributes.alpha);
00995                         this.setTint(ViewGalleryBtn.ViewIconFill, styleNode.attributes.color, styleNode.attributes.alpha);
00996                         //caption scroll buttons
00997                         this.setTint(this.SlideShowMetaData._btnUp.MetadataScrollBtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00998                         this.setTint(this.SlideShowMetaData._btnDown.MetadataScrollBtnBg, styleNode.attributes.color, styleNode.attributes.alpha);
00999                         break;
01000                 case "slideshowBtnFore" :
01001                         this.setTint(SlideShowVCRButtons.forward.BtnFore, styleNode.attributes.color, styleNode.attributes.alpha);
01002                         this.setTint(SlideShowVCRButtons.back.BtnFore, styleNode.attributes.color, styleNode.attributes.alpha);
01003                         this.setTint(SlideShowVCRButtons.PausePlay.Play.BtnFore, styleNode.attributes.color, styleNode.attributes.alpha);
01004                         this.setTint(SlideShowVCRButtons.PausePlay.Pause.BtnFore, styleNode.attributes.color, styleNode.attributes.alpha);
01005                         this.setTint(ViewSlideshowBtn.TextStroke, styleNode.attributes.color, styleNode.attributes.alpha);
01006                         this.setTint(ViewGalleryBtn.TextStroke, styleNode.attributes.color, styleNode.attributes.alpha);
01007                         this.setTint(ViewSlideshowBtn.ViewIconFore, styleNode.attributes.color, styleNode.attributes.alpha);
01008                         this.setTint(ViewGalleryBtn.ViewIconFore, styleNode.attributes.color, styleNode.attributes.alpha);
01009                         this.setTint(this.SlideShowMetaData._btnUp.MetadataScrollArrowUp, styleNode.attributes.color, styleNode.attributes.alpha);
01010                         this.setTint(this.SlideShowMetaData._btnDown.MetadataScrollArrowDown, styleNode.attributes.color, styleNode.attributes.alpha);
01011                         break;
01012                 case "imageBorder" :
01013                         this._iImageBorderWidth = parseFloat(styleNode.attributes.width);
01014                         this._iImageBorderColor = parseInt("0x"+styleNode.attributes.color);
01015                         this._iImageBorderAlpha = parseInt("0x"+styleNode.attributes.alpha);
01016                         for (var i:Number = 0; i<this.aMediaClips.length; i++) {
01017                                 this.aMediaClips[i].mediaClip._iBorderColor = this._iImageBorderColor;
01018                                 this.aMediaClips[i].mediaClip._iBorderAlpha = this._iImageBorderAlpha;
01019                                 this.aMediaClips[i].mediaClip._iBorderWidth = this._iImageBorderWidth;
01020                                 this.aMediaClips[i].mediaClip.setBorder();
01021                         }
01022                         this._iMaxImgWidth = this._iOrigMaxImgWidth+(_iImageBorderWidth*2);
01023                         this._iMaxImgHeight = this._iOrigMaxImgHeight+(_iImageBorderWidth*2);
01024                         this.setHeightWidth(this._iControlHeight, this._iControlWidth);
01025                         this.refreshClip();
01026                         break;
01027                 case "imageDropShadow" :
01028                         var dShadow:Boolean;
01029                         if (styleNode.attributes.enabled == "true") {
01030                                 dShadow = true;
01031                         } else {
01032                                 dShadow = false;
01033                         }
01034                         for (var i:Number = 0; i<this.aMediaClips.length; i++) {
01035                                 this.aMediaClips[i].mediaClip.bDropShadows = dShadow;
01036                                 this.aMediaClips[i].mediaClip.setBorder();
01037                         }
01038                         setHeightWidth(this._iControlHeight, this._iControlWidth);
01039                         break;
01040                 case "videoCtrlBgColor" :
01041                         break;
01042                 case "videoCtrlBtnBorder" :
01043                         break;
01044                 case "videoCtrlBtnBackground" :
01045                         break;
01046                 case "videoCtrlBtnFore" :
01047                         break;
01048                 case "videoDropShadow" :
01049                         break;
01050                 }
01051         }
01052 
01053         public function setHeightWidth(h:Number, w:Number):Void {
01054                 this._iControlWidth = w;
01055                 this._iControlHeight = h;
01056                 //Control Border and Background
01057                 this.SlideShowBg.drawRectangle(w, h, 7);
01058                 //this will dictate how much area is available for media display
01059                 var availHeight:Number = h;
01060                 var availWidth:Number = w;
01061                 if (this.aMediaClips.length>1) {
01062                         //center slideshow vcr controls at bottom of control
01063                         this.SlideShowVCRButtons._x = (this._iControlWidth/2)-(this.SlideShowVCRButtons._width/2);
01064                         this.SlideShowVCRButtons._y = this._iControlHeight-this.SlideShowVCRButtons._height-this._iControlsBottomSpacer;
01065                         availHeight = h-(this.SlideShowVCRButtons._height+this._iControlsBottomSpacer+_iControlsHorizSpacer);
01066                         this.SlideShowStatus._x = this.SlideShowVCRButtons._x+this.SlideShowVCRButtons._width+39;
01067                         this.SlideShowVCRButtons._visible = true;
01068                         this.SlideShowStatus._visible = true;
01069                 } else {
01070                         this.SlideShowVCRButtons._visible = false;
01071                         this.SlideShowStatus._visible = false;
01072                 }
01073                 
01074                 //change view buttons
01075                 this.ViewSlideshowBtn._x = this.ViewGalleryBtn._x=this.SlideShowVCRButtons._x-55;
01076                 this.ViewSlideshowBtn._y = this.ViewGalleryBtn._y=this._iControlHeight-this.ViewSlideshowBtn._height-this._iControlsBottomSpacer-3;
01077                 availHeight = h-(this.SlideShowVCRButtons._height+this._iControlsBottomSpacer+_iControlsHorizSpacer);
01078                 
01079                 if (_strViewMode == "slideshowOnly") {
01080                         this.ViewGalleryBtn._visible = false;
01081                         this.ViewSlideshowBtn._visible = false;
01082                 } else if (_strViewMode == "mapView") {
01083                         this.ViewMapBtn._x = (this._iControlWidth/2)-(this.SlideShowVCRButtons._width/2)-57;
01084                         this.ViewMapBtn._y = this._iControlHeight-this.ViewMapBtn._height-this._iControlsBottomSpacer;
01085                         availHeight = h-(this.SlideShowVCRButtons._height+this._iControlsBottomSpacer+_iControlsHorizSpacer);
01086                         this.ViewGalleryBtn._visible = false;
01087                         this.ViewSlideshowBtn._visible = false;
01088                         this.ViewMapBtn._visible = true;
01089                 } else {
01090                         //view toggle buttons
01091                         if (strCurrView == "gallery") {
01092                                 this.ViewGalleryBtn._visible = false;
01093                                 this.ViewSlideshowBtn._visible = true;
01094                                 availHeight = h-(this.SlideShowVCRButtons._height+this._iControlsBottomSpacer+_iControlsHorizSpacer);
01095                         } else if (strCurrView == "slideshow") {
01096                                 this.ViewGalleryBtn._visible = true;
01097                                 this.ViewSlideshowBtn._visible = false;
01098                                 //take care of scroll button 'flashing' problem
01099                                 //this.SlideShowMetaData.clearScrollButtons();
01100                                 availHeight = h-(this.SlideShowVCRButtons._height+this._iControlsBottomSpacer+_iControlsHorizSpacer);
01101                         }
01102                 }
01103                 //status message
01104                 this.SlideShowStatus._y = this._iControlHeight-this.SlideShowStatus._height+1;
01105                 
01106                 //media caption/metadata field
01107                 if (this._iSlideShowMetadataHeight>.8*this._iControlHeight) {
01108                         //this._iSlideShowMetadataHeight = .8*this._iControlHeight;
01109                 } else if (this._iSlideShowMetadataHeight<0) {
01110                         //this._iSlideShowMetadataHeight = 0;
01111                 }
01112                 this.SlideShowMetaData.setHeightWidth(this._iSlideShowMetadataHeight, this._iControlWidth-(_iControlsSideSpacer*2));
01113                 this.SlideShowMetaData._x = _iControlsSideSpacer;
01114                 this.SlideShowMetaData._y = this._iControlHeight-this.SlideShowVCRButtons._height-this._iControlsBottomSpacer-this._iSlideShowMetadataHeight-_iControlsHorizSpacer;
01115                 this.SlideShowMetaData._visible = true;
01116                 availHeight -= this._iSlideShowMetadataHeight+_iControlsHorizSpacer;
01117                 if (this._strMediaPostionType == "auto") {
01118                         availHeight -= this._iImageCanvasTopSpacer;
01119                         availWidth -= (2*this._iImageCanvasRightSpacer);
01120                         this.ImageCanvas._x = this._iImageCanvasRightSpacer;
01121                         this.ImageCanvas._y = this._iImageCanvasTopSpacer;
01122                         _iImageCanvasHeight = availHeight;
01123                         _iImageCanvasWidth = availWidth;
01124                 } else if (this._strMediaPostionType == "fixed") {
01125                         var myPoint:Object = new Object();
01126                         myPoint.x = this.mediaXPos;
01127                         myPoint.y = this.mediaYPos;
01128                         this.globalToLocal(myPoint);
01129                         this.ImageCanvas._x = myPoint.x;
01130                         this.ImageCanvas._y = myPoint.y;
01131                         _iImageCanvasHeight = this.mediaHeight;
01132                         _iImageCanvasWidth = this.mediaWidth;
01133                 }
01134                 //if fit at start, find the biggest image that will fit the image canvas size 
01135                 if (_bFitAtStart) {
01136                         _bFitAtStart = false;
01137                         this.findBestFit();
01138                 }
01139                 this.ImageCanvasMask._x = this.ImageCanvas._x;
01140                 this.ImageCanvasMask._y = this.ImageCanvas._y;
01141                 this.setImageCanvasMask(_iImageCanvasWidth, _iImageCanvasHeight);
01142                 /* SHADE IMAGE CANVAS
01143                 this.ImageCanvas.clear();
01144                 this.ImageCanvas.beginFill(0x666666,100);
01145                 this.ImageCanvas.moveTo(0,0);
01146                 this.ImageCanvas.lineTo(_iImageCanvasWidth,0);
01147                 this.ImageCanvas.lineTo(_iImageCanvasWidth,_iImageCanvasHeight);
01148                 this.ImageCanvas.lineTo(0,_iImageCanvasHeight);
01149                 this.ImageCanvas.lineTo(0,0);
01150                 this.ImageCanvas.endFill();
01151                 */
01152                 this.ScrollBtnUp._visible = false;
01153                 this.ScrollBtnDown._visible = false;
01154                 this.ScrollBtnRight._visible = false;
01155                 this.ScrollBtnLeft._visible = false;
01156                 this.ScrollLineHoriz._visible = false;
01157                 this.ScrollLineVert._visible = false;
01158                 this.ScrollThumbHoriz._visible = false;
01159                 this.ScrollThumbVert._visible = false;
01160                 this.ScrollThumbMarksHoriz._visible = false;
01161                 this.ScrollThumbVert._visible = false;
01162                 this.ScrollThumbMarksHoriz._visible = false;
01163                 this.ScrollThumbMarksVert._visible = false;
01164                 //determine media scaling based on image canvas size
01165                 var scalar:Number;
01166                 switch (this.aMediaClips[this._iCurrentClip].mediaClipType) {
01167                 case "image" :
01168                         switch (_strImageScale) {
01169                                 case "fitToScreen" :
01170                                         scalar = 1;
01171                                         var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.width*scalar)/2);
01172                                         var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)/2);
01173                                         this.aMediaClips[_iCurrentClip].mediaClip.moveMedia(newxpos, newypos);
01174                                         this.RenditionProgress._x = this.ImageCanvas._x + (_iImageCanvasWidth/2) - (this.RenditionProgress._width/2);
01175                                         this.RenditionProgress._y = this.ImageCanvas._y + (_iImageCanvasHeight/2);
01176                                         
01177                                         var bestFit:Object = null;
01178                                         
01179                                         if((_iImageCanvasWidth >=_oSmallRendition.maxwidth) && (_iImageCanvasHeight >=_oSmallRendition.maxheight))
01180                                                         bestFit = this._oSmallRendition;
01181                                         if((_iImageCanvasWidth >=_oMedRendition.maxwidth) && (_iImageCanvasHeight >=_oMedRendition.maxheight))
01182                                                         bestFit = this._oMedRendition
01183                                         if((_iImageCanvasWidth >=_oLargeRendition.maxwidth) && (_iImageCanvasHeight >=_oLargeRendition.maxheight))
01184                                                         bestFit = this._oLargeRendition;                                                
01185                                         
01186                                         if(bestFit == null){
01187                                                         scalar = 1;
01188                                                 if (this.aMediaClips[this._iCurrentClip].mediaClip.width>_iImageCanvasWidth) {
01189                                                         scalar = (_iImageCanvasWidth/this.aMediaClips[this._iCurrentClip].mediaClip.width);
01190                                                 }
01191                                                 if ((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)>_iImageCanvasHeight) {
01192                                                         scalar = (_iImageCanvasHeight/this.aMediaClips[this._iCurrentClip].mediaClip.height);
01193                                                 }
01194                                                 this.aMediaClips[this._iCurrentClip].mediaClip.scaleMedia(scalar*100);
01195                                                 var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.width*scalar)/2);
01196                                                 var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)/2);
01197                                                 this.aMediaClips[_iCurrentClip].mediaClip.moveMedia(newxpos, newypos);
01198                                         }
01199                                         else if(bestFit.size != this._strCurrImgSize){
01200                                                 //abort currently loading clip
01201                                                 this.aMediaClips[_iCurrentClip].mediaClip.abortLoad();
01202                                                 //mark clips as unloaded
01203                                                 for (var i:Number=0; i<this.aMediaClips.length; i++) {
01204                                                         this.aMediaClips[i].mediaClip.iPercentLoaded = 0;
01205                                                 }
01206                                                 _root.gallery.dispatchEvent("changeImageSize", bestFit.size);
01207                                                 this.RenditionProgress.SlideShowStatusText.txtSlideNumber.text = this.strSizeLoading;
01208                                                 this.RenditionProgress._visible = true;
01209                                                 this._strCurrImgSize = bestFit.size;
01210                                         }
01211                                 break;
01212                                 default:
01213                                         //determine media scaling based on image canvas size
01214                                         scalar = 1;
01215                                         if (this.aMediaClips[this._iCurrentClip].mediaClip.width>_iImageCanvasWidth) {
01216                                                 scalar = (_iImageCanvasWidth/this.aMediaClips[this._iCurrentClip].mediaClip.width);
01217                                         }
01218                                         if ((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)>_iImageCanvasHeight) {
01219                                                 scalar = (_iImageCanvasHeight/this.aMediaClips[this._iCurrentClip].mediaClip.height);
01220                                         }
01221                                         this.aMediaClips[this._iCurrentClip].mediaClip.scaleMedia(scalar*100);
01222                                         var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.width*scalar)/2);
01223                                         var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)/2);
01224                                         this.aMediaClips[_iCurrentClip].mediaClip.moveMedia(newxpos, newypos);
01225                         }
01226                         this.aMediaClips[_iCurrentClip].mediaClip.moveMedia(newxpos, newypos);
01227                         break;
01228                 case "video" :
01229                         if ((_strImageScale == "none") || (_strVideoScale == "none")) {
01230                                 scalar = 1;
01231                         } else if ((_strImageScale == "downOnly") || (_strVideoScale == "downOnly")) {
01232                                 //scale down if needed
01233                                 if (this.aMediaClips[this._iCurrentClip].mediaClip.width>_iImageCanvasWidth) {
01234                                         scalar = (_iImageCanvasWidth/this.aMediaClips[this._iCurrentClip].mediaClip.width);
01235                                 }
01236                                 if ((this.aMediaClips[this._iCurrentClip].mediaClip.height*scalar)>_iImageCanvasHeight) {
01237                                         scalar = (_iImageCanvasHeight/this.aMediaClips[this._iCurrentClip].mediaClip.height);
01238                                 }
01239                         } else if (_strImageScale == "upDown") {
01240                                 trace("--UP DOWN--");
01241                         }
01242                         this.aMediaClips[_iCurrentClip].mediaClip.setHeightWidth(_iImageCanvasHeight, _iImageCanvasWidth, this._strVideoScale);
01243                         var newxpos:Number = (this._iImageCanvasWidth/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.width)/2);
01244                         var newypos:Number = (this._iImageCanvasHeight/2)-((this.aMediaClips[this._iCurrentClip].mediaClip.height)/2);
01245                         this.aMediaClips[_iCurrentClip].mediaClip.moveMedia(newxpos, newypos);
01246                         break;
01247                 }
01248         }
01249         
01250         private function checkImageScrolling(){
01251                 
01252         }
01253         
01254         public function scrollImageUp() {
01255                 trace("scroll up");
01256         }
01257         public function scrollImageDown() {
01258                 if ((this.ScrollThumbVert._y+this.ScrollThumbVert._height+5)>(this.ScrollLineVert._y+this.ScrollLineVert._height)) {
01259                         this.ScrollThumbVert._y = this.ScrollLineVert._y+this.ScrollLineVert._height-this.ScrollThumbVert._height;
01260                 } else {
01261                         this.ScrollThumbVert._y += 5;
01262                 }
01263                 this.checkVertScrollPos();
01264         }
01265         public function scrollImageRight() {
01266                 trace("scroll right");
01267         }
01268         public function scrollImageLeft() {
01269                 trace("scroll left");
01270         }
01271         public function checkVertScrollPos() {
01272                 var scrollPercentage:Number = (this._y-this._parent.ScrollLineVert._y)/this._parent._iVertScrollDistance;
01273                 var maxVertImgOffset:Number = this._parent.aMediaClips[this._parent._iCurrentClip].mediaClip.height-this._parent._iImageCanvasHeight;
01274                 if (scrollPercentage<0) {
01275                         scrollPercentage = 0;
01276                 }
01277                 var scrollDistance:Number = -1*scrollPercentage*maxVertImgOffset;
01278                 this._parent.ImageCanvas._y = this._parent._iImageCanvasTopSpacer+(-1*scrollPercentage*maxVertImgOffset);
01279         }
01280         public function checkHorizScrollPos() {
01281                 var scrollPercentage:Number = (this._x-this._parent.ScrollLineHoriz._x)/this._parent._iHorizScrollDistance;
01282                 var maxHorizImgOffset:Number = this._parent.aMediaClips[this._parent._iCurrentClip].mediaClip.width-this._parent._iImageCanvasWidth;
01283                 if (scrollPercentage<0) {
01284                         scrollPercentage = 0;
01285                 }
01286                 var scrollDistance:Number = -1*scrollPercentage*maxHorizImgOffset;
01287                 this._parent.ImageCanvas._x = this._parent._iImageCanvasTopSpacer+(-1*scrollPercentage*maxHorizImgOffset);
01288         }
01289         public function scrollThumbVertDrag() {
01290                 this.onEnterFrame = this._parent.checkVertScrollPos;
01291                 this._parent._bVertScrollUsed = true;
01292                 startDrag(this, false, this._x, this._parent.ScrollLineVert._y, this._x, this._parent._iVertScrollDistance+this._parent.ScrollLineVert._y);
01293         }
01294         public function scrollThumbVertStopDrag() {
01295                 this.onEnterFrame = null;
01296                 stopDrag();
01297         }
01298         public function scrollThumbHorizDrag() {
01299                 this.onEnterFrame = this._parent.checkHorizScrollPos;
01300                 this._parent._bHorizScrollUsed = true;
01301                 startDrag(this, false, this._parent.ScrollLineHoriz._x, this._y, this._parent._iHorizScrollDistance+this._parent.ScrollLineHoriz._x, this._y);
01302         }
01303         public function scrollThumbHorizStopDrag() {
01304                 this.onEnterFrame = null;
01305                 stopDrag();
01306         }
01307         
01308         
01309         function findBestFit(){
01310                 var largestFittingWidth:Number = 0;
01311                 var iImageRenditionIndex = -1;
01312                 var shadowWidth:Number = 0;
01313                 var setFirstSize:Boolean = true;
01314                 if (_bDropShadows) {
01315                         shadowWidth = 4;
01316                 }
01317                 
01318                 for (var i:Number = 0; i<this._aImageRenditions.length; i++) {
01319                         //if the rendition is for an image...
01320                         if ((this._aImageRenditions[i].size != "video") && (this._aImageRenditions[i].size != "thumb")) {
01321                                 
01322                                 if(setFirstSize){
01323                                         //make sure we get at least one value
01324                                    iImageRenditionIndex = i;
01325                                    setFirstSize = false;
01326                                 }
01327                                 //and the image will fit on the canvas...
01328                                 if (((this._aImageRenditions[i].maxwidth+(2*_iImageBorderWidth)+shadowWidth)<=_iImageCanvasWidth) && ((this._aImageRenditions[i].maxheight+(2*_iImageBorderWidth)+shadowWidth)<=_iImageCanvasHeight)) {
01329                                         //get the index of the largest size that will fit
01330                                         if (this._aImageRenditions[i].maxwidth>largestFittingWidth) {
01331                                                 largestFittingWidth = (this._aImageRenditions[i].maxwidth+(2*_iImageBorderWidth)+shadowWidth);
01332                                                 iImageRenditionIndex = i;
01333                                         }
01334                                 }
01335                         }
01336                 }
01337                 
01338                 if (iImageRenditionIndex>=0) {
01339                         //set values the next largest dimesions for auto sizing
01340                         _root.gallery.dispatchEvent("changeImageSize", this._aImageRenditions[iImageRenditionIndex].size);
01341                         return;
01342                 }
01343         }
01344         
01345         
01346         private function setImageCanvasMask(w, h) {
01347                 this.ImageCanvasMask.clear();
01348                 this.ImageCanvasMask.beginFill(0x000000);
01349                 this.ImageCanvasMask.moveTo(0, 0);
01350                 this.ImageCanvasMask.lineTo(w, 0);
01351                 this.ImageCanvasMask.lineTo(w, h);
01352                 this.ImageCanvasMask.lineTo(0, h);
01353                 this.ImageCanvasMask.lineTo(0, 0);
01354                 this.ImageCanvasMask.endFill();
01355         }
01356         /**************************************************************
01357         ** setTint
01358         ** Sets a color object for a movieclip and then sets its tint
01359         ** allowing for ActionScript control of display colors
01360         ****************************************************************/
01361         function setTint(clip:MovieClip, hexval:String, alpha:String):Void {
01362                 hexval = "0x"+hexval;
01363                 var colorVal = parseInt(hexval);
01364                 var alphaVal = parseInt(alpha);
01365                 var color:Color = new Color(clip);
01366                 var oColorTransform:Object = new Object();
01367                 oColorTransform.ra = oColorTransform.ga=oColorTransform.ba=0;
01368                 oColorTransform.rb = (colorVal >> 16) & 0xFF;
01369                 oColorTransform.gb = (colorVal >> 8) & 0xFF;
01370                 oColorTransform.bb = colorVal & 0xFF;
01371                 oColorTransform.ab = ((alphaVal/100)*255)-255;
01372                 color.setTransform(oColorTransform);
01373         }
01374 }

Copyright © 2006 Adobe Systems Incorporated.

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