0 Replies Latest reply on Jul 16, 2007 1:49 PM by serg2049

    xml flash slideshow

    serg2049
      I have this code, it works, but I only get one text field for description when clicking on a thumbnail. I need 3 textfields on top the name, then the description, and on bottom a text field for a number. How can I add thos other two? I tried and it kind of worked but it became a mess, cause the code counts the number of images, so when I add more childnodes for the name and number it messes up. HEre's the code:


      /* -----------------------------------------------------------------

      all design and code copyright (c) www.lukamaras.com

      ----------------------------------------------------------------- */
      /* -------------------- setting the variables -------------------- */
      var menuSpeed:Number = 6;
      var menuDown:Button = menuDown_btn;
      var menuUp:Button = menuUp_btn;
      menuUp._alpha = 0;
      menuUp.enabled = false;
      var firstLook:Boolean = true;
      var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
      var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;
      galleryMask._height = 391;
      var imagesHolder:MovieClip = imagesHolder_mc;
      var descText:TextField = desc_txt;
      var imagesInGallery:Array = new Array();
      var galleryNames:Array = new Array();
      var galleryIntros:Array = new Array();
      var descriptions:Array = new Array();
      var tracker:Number = new Number();
      var whatIsLoading:String = new String();
      var galleryBtnLeftMargin:Number = 10;
      var galleryBtnUpperMargin:Number = 60;
      var galleryBtnVSpace:Number = 23;
      var thumbMarginX:Number = 96;
      var thumbMarginY:Number = 68;
      /* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */
      imagesHolder._x = 243;
      imagesHolder._y = galleryBtnUpperMargin;
      logo_mc._x = logo_mc._y=galleryBtnLeftMargin;
      desc_txt._x = 243;
      desc_txt._y = 400;
      /* -------------------- The welcome text -------------------- */
      descText.text = "Click on a gallery name on the left to load its thumbnails. Remember, you can click on a thumbnail only when all the thumbnails in a gallery have been loaded. When you click on a thumbnail to see the big image, clicking on the big image will close it and you will return to the gallery. Use the button(s) above the galleries to scroll through them.";
      /* -------------------- Importing and defining the DropShadow filter -------------------- */
      import flash.filters.DropShadowFilter;
      var shadowEffect:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 100, 3, 3, 1, 3);
      var thumbsFilter:Array = [shadowEffect];
      /* -------------------- MovieClipLoader & Listener -------------------- */
      var loader:MovieClipLoader = new MovieClipLoader();
      var myListener:Object = new Object();
      loader.addListener(myListener);
      myListener.onLoadInit = function(target:MovieClip) {
      if (whatIsLoading == "thumb") {
      currentThumbnail.percent_txt._visible = false;
      currentThumbnail.filters = thumbsFilter;
      thumbClickable();
      tracker++;
      if (tracker<howManyImages) {
      loadThumbnail();
      } else {
      enableThumbs();
      }
      } else if (whatIsLoading == "big") {
      target._alpha = 0;
      displayBigImage.percent_txt._visible = false;
      displayBigImage.filters = thumbsFilter;
      bigClickable();
      fadeIn();
      }
      };
      myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
      percent = Math.floor(loaded/total*100);
      if (whatIsLoading == "thumb") {
      currentThumbnail.percent_txt._visible = true;
      currentThumbnail.percent_txt.text = percent+"%";
      } else if (whatIsLoading == "big") {
      displayBigImage.percent_txt._visible = true;
      displayBigImage.percent_txt.text = percent+"%";
      }
      };
      /* -------------------- loading XML -------------------- */
      var imageGallery:XML = new XML();
      imageGallery.ignoreWhite = true;
      imageGallery.onLoad = function(success) {
      if (success) {
      parseGalleries();
      } else {
      descText.text = "Sorry the image data just didn't load.";
      }
      };
      imageGallery.load("gallery/gallery.xml");
      /* -------------------- parsing XML -------------------- */
      function parseGalleries():Void {
      if (imageGallery.firstChild.nodeName == "galleries") {
      var rootNode:XMLNode = imageGallery.firstChild;
      for (i=0; i<rootNode.childNodes.length; i++) {
      if (rootNode.childNodes .nodeName == "gallery") {
      currentGallery = rootNode.childNodes
      ;
      imagesInGallery.push(currentGallery.childNodes.length);
      galleryNames.push(currentGallery.attributes.title);
      galleryIntros.push(currentGallery.attributes.intro);
      currentGalleryTitle = rootNode.childNodes .attributes.title;
      currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
      currentGalleryButton._x = 0;
      currentGalleryButton._y = galleryBtnVSpace*i;
      currentGalleryButton.sectionTitle_txt.text = "0"+(i+1)+" "+currentGalleryTitle.toUpperCase();
      for (j=0; j<currentGallery.childNodes.length; j++) {
      if (currentGallery.childNodes[j].nodeName == "image") {
      currentDescription = currentGallery.childNodes[j].firstChild.toString();
      descriptions.push(currentDescription);
      }
      }
      }
      }
      }
      numberOfGalleries = i;
      enableButtons(numberOfGalleries);
      }
      function enableButtons(numberOfGalleries:Number):Void {
      for (i=0; i<numberOfGalleries; i++) {
      pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
      pressedButton.onRollOver = function():Void {
      this.gotoAndStop(2);
      };
      pressedButton.onRollOut = function():Void {
      this.gotoAndStop(1);
      };
      pressedButton.onPress = function():Void {
      removeMovieClip(thumbsDisplayer);
      removeMovieClip(displayBigImage);
      tracker = 0;
      thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
      clickedGallery = Number(this._name.substr(13));
      howManyImages = imagesInGallery[clickedGallery];
      whichGallery = galleryNames[clickedGallery];
      descText.text = galleryIntros[clickedGallery];
      currentRow = 0;
      currentColumn = 0;
      loadThumbnail();
      };
      }
      enableGalleryNavigation();
      }
      function loadThumbnail() {
      currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
      target = currentThumbnail.thumbImage_mc;
      if ((tracker%5) == 0 && tracker != 0) {
      currentRow += 1;
      }
      if (currentColumn>3) {
      currentColumn = 0;
      } else if (tracker == 0) {
      currentColumn = 0;
      } else {
      currentColumn += 1;
      }
      currentThumbnail._x = currentColumn*thumbMarginX;
      currentThumbnail._y = currentRow*thumbMarginY;
      currentThumbnail.percent_txt._visible = true;
      thumbNumber = currentThumbnail._name.substr(9);
      thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";
      whatIsLoading = "thumb";
      loader.loadClip(thumbPath, target);
      }
      function thumbClickable():Void {
      currentThumbnail.onPress = function() {
      bigNumber = this._name.substr(9);
      displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
      target = displayBigImage.imageHolder_mc;
      bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
      whatIsLoading = "big";
      disableThumbs();
      loader.loadClip(bigImagePath, target);
      if (clickedGallery>0) {
      var descPosition:Number = 0;
      for (i=0; i<clickedGallery; i++) {
      descPosition += imagesInGallery
      ;
      }
      descPosition = descPosition+Number(bigNumber)-1;
      imageDesc = descriptions[descPosition];
      } else {
      imageDesc = descriptions[Number(bigNumber)-1];
      }
      descText.text = imageDesc;
      };
      currentThumbnail.enabled = false;
      }
      function disableThumbs():Void {
      for (i=0; i<howManyImages; i++) {
      thumbsDisplayer["thumbnail"+(i+1)].enabled = false;
      }
      }
      function enableThumbs():Void {
      for (i=0; i<howManyImages; i++) {
      thumbsDisplayer["thumbnail"+(i+1)].enabled = true;
      }
      }
      function bigClickable():Void {
      displayBigImage.onPress = function() {
      removeMovieClip(this);
      enableThumbs();
      descText.text = galleryIntros[clickedGallery];
      };
      }
      function fadeIn():Void {
      target.onEnterFrame = function():Void {
      this._alpha += 10;
      if (this._alpha>=100) {
      delete this.onEnterFrame;
      this._alpha = 100;
      }
      };
      }
      function enableGalleryNavigation():Void {
      menuDown.onPress = function() {
      if (firstLook) {
      menuUp._alpha = 100;
      menuUp.enabled = true;
      firstLook = false;
      }
      var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
      if (menuButtons._y<=0 && menuTop>=galleryMask._height) {
      var targetPos:Number = menuButtons._y-galleryMask._height;
      menuDown.enabled = false;
      menuUp.enabled = false;
      menuButtons.onEnterFrame = function():Void {
      menuButtons._y += (targetPos-menuButtons._y)/menuSpeed;
      if (menuButtons._y<=(targetPos+0.8)) {
      menuButtons._y = Math.round(targetPos);
      delete menuButtons.onEnterFrame;
      menuDown.enabled = true;
      menuUp.enabled = true;
      }
      };
      }
      };
      menuUp.onPress = function() {
      var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
      if (menuButtons._y<0 && menuTop>0) {
      var targetPos:Number = menuButtons._y+galleryMask._height;
      menuDown.enabled = false;
      menuUp.enabled = false;
      menuButtons.onEnterFrame = function():Void {
      menuButtons._y += (-menuButtons._y+targetPos)/menuSpeed;
      if (menuButtons._y>=(targetPos-0.8)) {
      menuButtons._y = Math.round(targetPos);
      delete menuButtons.onEnterFrame;
      menuDown.enabled = true;
      menuUp.enabled = true;
      }
      };
      }
      };
      }