Código:
/*-------------------------------------- * * May 2007 * Slideshow 2 - XML. * * Copyright © 2007 by Andrei Potorac * All rights reserved. * * * If you want to change the size of the stage, you also need to change these variables in the code: * * var sWidth:Number = 900; * var sHeight:Number = 390; * * The output panel will tell you what should be the width of the images * and the height should be the same as the stage height. ---------------------------------------*/ Stage.scaleMode = "noScale"; Stage.align = "TL"; Stage.showMenu = false; this._lockroot = true; /******************** General settings ********************/ var sWidth:Number = 900; var sHeight:Number = 600; var nrFrames:Number = 30; var allImagesLoaded:Boolean = false; w = sHeight*100/390; mcButNext._width = mcButNext._width*w/100; mcButBack._width = mcButBack._width*w/100; var sizeHolder:Number = mcButNext._width; var movePos:Number = Math.floor(sWidth-2*sizeHolder); trace("This is the width the images should have: "+movePos+" (the stage width is "+sWidth+" pixels)"); mcButNext._height = sHeight; mcButBack._height = sHeight; var mclListener:Object = new Object(); mclListener.onLoadInit = function(mc:MovieClip) { mc._parent.mcBut._xscale = 100*mc._width; mc._parent.mcBut._yscale = 100*mc._height; mc._parent._x = int(sizeHolder); sizeHolder += mc._width; if (contor<nrThumbs-1) { mc.fade("in", 5); contor++; image_mcl.loadClip(thumbsArray[contor], mcThumbsHorizontal["mcThumbItem"+contor].mcHolder); } else { allImagesLoaded = true; mc.fade("in", 5); mcLoader._visible = false; startAnimationHorizontal(); } }; var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); /******************** VARIABLES ********************/ var thumbsArray:Array = new Array(); var linkArray:Array = new Array(); var targetArray:Array = new Array(); var contor:Number = 0; var over:Boolean = false; var currentImage:Number = 0; var alphaVal:Number; var alphaMin:Number = 30; // mcThumbsHorizontal.mcThumbItem._visible = false; mcThumbsHorizontal.setMask(mcMaskHorizontal); mcMaskHorizontal._width = sWidth; mcMaskHorizontal._height = sHeight; // mcButNext._x = sWidth; mcButBack._x = mcButNext._y=0; mcButNext._visible = false; mcButBack._visible = false; mcLoader._visible = false; mcLoader._x = (sWidth-mcLoader._width)/2; mcLoader._y = (sHeight-mcLoader._height)/2; createEmptyMovieClip("mcCount", this.getNextHighestDepth()); /******************** PARSE XML ********************/ var HOME:MovieClip = this; var settingsArray:Array = new Array(); var settingsXml:Parse = new Parse("gallery.xml", HOME.initXml); // function initXml():Void { var mainNode:XMLNode = HOME.settingsXml.myXml.firstChild; var i:Number = 0; for (var currentNode = mainNode.firstChild; currentNode != null; currentNode=currentNode.nextSibling, i++) { var j:Number = 0; settingsArray[i] = new Array(); for (var childNode = currentNode.firstChild; childNode != null; childNode=childNode.nextSibling, j++) { settingsArray[i][j] = childNode.firstChild.nodeValue; //trace("settingsArray["+i+"]["+j+"]= "+settingsArray[i][j]); if (i == 0) { thumbsArray[j] = settingsArray[i][j]; linkArray[j] = childNode.attributes.link; targetArray[j] = childNode.attributes.target; } } } timeCounter = int(settingsArray[1][0]); mcButNext.mcShape.setColor(settingsArray[1][1]); mcButBack.mcShape.setColor(settingsArray[1][1]); alphaVal = int(settingsArray[1][2]); loopMode = settingsArray[1][3]; // mcButBack.mcBut.but.enabled = false; mcButBack._alpha = alphaMin; // //mcButNext.mcBut.but.enabled = false; mcButNext._alpha = alphaMin; // mcButNext._visible = true; mcButBack._visible = true; // nrThumbs = thumbsArray.length; createHorizontalThumbs(); } //************************************************************// // COUNT TIME //************************************************************// function countTime():Void { c = 0; mcCount.onEnterFrame = function() { c++; if (c/nrFrames == timeCounter) { if (settingsArray[0].length-1>=Math.abs(currentImage)+1) { currentImage--; mcButBack.mcBut.but.enabled = true; mcButBack._alpha = alphaVal; if (settingsArray[0].length-1>=Math.abs(currentImage)+1) { mcButBack._alpha = alphaVal; } else { mcButNext.mcBut.but.enabled = false; mcButNext._alpha = alphaMin; } mcThumbsHorizontal.elastic({_x:movePos*currentImage}, 5); } else { if (loopMode == "true") { currentImage = 0; mcButNext.mcBut.but.enabled = true; mcButNext._alpha = alphaVal; mcButBack.mcBut.but.enabled = true; mcButBack._alpha = alphaVal; if (settingsArray[0].length-1 >= Math.abs(currentImage)+1) { mcButBack._alpha = alphaVal; } mcThumbsHorizontal.elastic({_x:movePos*currentImage}, 5); } else { mcButNext.mcBut.but.enabled = false; mcButNext._alpha = alphaMin; } } c = 0; } }; } // //************************************************************// // INIT //************************************************************// function createHorizontalThumbs():Void { for (i=0; i<nrThumbs; i++) { mcThumbsHorizontal.mcThumbItem.duplicateMovieClip("mcThumbItem"+i, i); var t:MovieClip = mcThumbsHorizontal["mcThumbItem"+i]; pix[i] = t; t.nr = i; t.mcHolder._alpha = 0; if (linkArray[i] == undefined || linkArray[i] == "") { t.mcBut.but.enabled = false; } t.mcBut.but.onRelease = function():Void { if (linkArray[this._parent._parent.nr] != undefined) { getURL(linkArray[this._parent._parent.nr], targetArray[this._parent._parent.nr]); } }; t.mcBut.but.onRollOver = function():Void { over = true; }; t.mcBut.but.onRollOut = function():Void { over = false; }; t.mcBut.but.onReleaseOutside = function():Void { over = false; }; } mcLoader._visible = true; image_mcl.loadClip(thumbsArray[contor], mcThumbsHorizontal["mcThumbItem"+contor].mcHolder); } //************************************************************// // MOVEMENT //************************************************************// createEmptyMovieClip("mcAnimation", -2); function startAnimationHorizontal():Void { mcThumbsHorizontal.x = 250; mcThumbsHorizontal.cacheAsBitmap = true; countTime(); } //************************************************************// // CONTROLLER //************************************************************// mcButBack.mcBut.but.onRelease = function():Void { c = 0; if (currentImage<0) { currentImage++; mcButNext.mcBut.but.enabled = true; mcButNext._alpha = alphaVal; if (currentImage != 0) { mcButBack._alpha = alphaVal; } else { mcButBack.mcBut.but.enabled = false; mcButBack._alpha = alphaMin; } mcThumbsHorizontal.elastic({_x:movePos*currentImage}, 5); } else { mcButBack.mcBut.but.enabled = false; mcButBack._alpha = alphaMin; } }; mcButBack.mcBut.but.onRollOver = function():Void { this._parent._parent.mcShape._alpha = 60; }; mcButBack.mcBut.but.onRollOut = function():Void { this._parent._parent.mcShape._alpha = 100; }; mcButNext.mcBut.but.onRelease = function():Void { c = 0; if (settingsArray[0].length-1>=Math.abs(currentImage)+1) { currentImage--; if (allImagesLoaded == true) { mcButBack.mcBut.but.enabled = true; } mcButBack._alpha = alphaVal; if (settingsArray[0].length-1>=Math.abs(currentImage)+1) { mcButBack._alpha = alphaVal; } else { mcButNext.mcBut.but.enabled = false; mcButNext._alpha = alphaMin; } mcThumbsHorizontal.elastic({_x:movePos*currentImage}, 5); } else { mcButNext.mcBut.but.enabled = false; mcButNext._alpha = alphaMin; } }; mcButNext.mcBut.but.onRollOver = function():Void { this._parent._parent.mcShape._alpha = 60; }; mcButNext.mcBut.but.onRollOut = function():Void { this._parent._parent.mcShape._alpha = 100; };