Aca les paso el xml:
Código XML :
<gallery title="ANTEOJOS" thumbDir="./images/thumbs/" imageDir="./images/" random="true"> <category name="anteojos 2011"> <image> <date>01.01.11</date> <title>nuevo anteojos</title> <desc>ultimo modelo</desc> <thumb>anteojos.jpg</thumb> <img>anteojo1.jpg</img> </image> </category>
Aca les paso el AS (es largo):
Código ActionScript :
stop();
#include "mc_tween2.as"
#include "xmlsa.as"
#include "timer.as"
// two views ? catView : thumbView
var viewMode = "catView"; // when page is first viewed show all the categories.
var viewRand = true; // on/off random preview
var catCol = 4; // number of columns for category
var numCatDisplay = 12; // max number of categories to show per page
var numThumbDisplay = 12; // max number of thumbnails to show per page
var catColXgap = 8; // gap between categories
var catColYgap = 180;
var dropDown = false;
var curImage = 0;
var curCat = 0;
// slideshow switch
var autoSlide = true;
// default transition speed
var defTranSpeed = 300;
catView_btn._alpha = 0;
// load the xml data
gallery = new XMLSA();
gallery.load("gallery.xml");
gallery.onLoad = function(ok){
   if (ok) {
      parseXml();
   } else {
      // error branch
      trace("error");
   }
}
/* loading stylesheet // not being used for image gallery but can be added later
function loadCss() {
   styles = new TextField.StyleSheet();
   css = "styles.css";
   styles.load(css);
   styles.onLoad = function(loaded) {
      if (loaded) {
         cssLoaded = true;
      } else {
         cssLoaded = false;
      }
      parseXml();
   }
}
*/
function parseXml() {
   //DEBUG
   //trace(gallery.dump());
   
   myGallery = new Array();
   
   // gallery title
   galleryTitle = gallery.attributes.title;
   title_txt.text = galleryTitle;
   
   // thumbanil directory
   thumbDir = gallery.attributes.thumbDir;
   // image directory
   imageDir = gallery.attributes.imageDir;
   // random ? true : false
   viewRandom = gallery.attributes.random;
   if(viewRandom == "true") {
      viewRand = true;
   } else {
      viewRand = false;
   }
   // parse information
   catTotal = gallery.category.length;
   for(var i=0; i<catTotal; i++) { //looping through categories
      myGallery[i] = new Array();
      myGallery[i]["name"] = gallery.category[i].attributes.name;
      myGallery[i]["image"] = new Array();
      //trace(myGallery[i]["name"]);
      var imageCount = gallery.category[i].image.length;
      for(var k=0; k<imageCount; k++) { //looping through images
         myGallery[i]["image"][k] = new Array();
         myGallery[i]["image"][k]["date"] = gallery.category[i].image[k].date.getValue();
         myGallery[i]["image"][k]["title"] = gallery.category[i].image[k].title.getValue();
         myGallery[i]["image"][k]["desc"] = gallery.category[i].image[k].desc.getValue();
         myGallery[i]["image"][k]["thumb"] = gallery.category[i].image[k].thumb.getValue();
         myGallery[i]["image"][k]["img"] = gallery.category[i].image[k].img.getValue();
         //trace(myGallery[i]["image"][k]["date"]);
      }
   }
   
   // determine the number of pages needed
   if(catTotal > numCatDisplay) {
      catNumPages = Math.ceil(catTotal/numCatDisplay);
   } else {
      // if categories are less than the limit only one page is needed
      catNumPages = 1;
   }
   
   // start from first page
   catPageCounter = 1;
   
   // start from 0;
   var pos = 0;
   
   // output page status
   page_txt.text = catPageCounter+" of "+catNumPages;
   
   prevBtn(catPageCounter);
   nextBtn(catPageCounter,catNumPages);
   
   //disable catViewBtn
      catView_btn.enabled = false;
   
   loadCat(pos);
   loadDropDown();
   catView_btn.onRelease = function() {
      catPageCounter = 1;
      
      _root.viewMode = "catView";
      
      loadCat(0);
      catView_btn.enabled = false;
      catView_btn.alphaTo(0, 1);
      dropDownBtn_mc.catName_txt.text = "Choose a category";
      if(dropDown) {
         doDropDown();
      }
      // output page status
      page_txt.text = catPageCounter+" of "+catNumPages;
      prevBtn(catPageCounter);
      nextBtn(catPageCounter, catNumPages);
   }   
}
function enableCatViewBtn() {
   catView_btn.enabled = true;
   catView_btn.alphaTo(100, 1);
}
   
      
      
function loadDropDown() {
   
   // if less than 7 categories, shorten the dropdown bg
   if(catTotal < 8) {
      // height of each category buttons
      var catBtnHeight = 20+3; // include the gaps
      var bgHeight = catTotal * catBtnHeight;
      bgHeight += 20; //include the top padding
      dropDown_mc.bg_mc.tween("_height", bgHeight, 1);
   }
   
   
   var temp = dropDown_mc.createEmptyMovieClip("temp", _root.getNextHighestDepth());
   
   var i=0;
   
   temp.onEnterFrame = function(){
      if(catTotal>i){
         
         //trace(i);
         var DropDownBtn = dropDown_mc.catBtn_mc.attachMovie("dropDownBtn", "dropDownBtn_mc"+i, i);
         
         DropDownBtn._alpha = 0;
         DropDownBtn.alphaTo(100, 3);
         
         DropDownBtn._y = Math.round(Number(DropDownBtn._height+3) * i);
         DropDownBtn.catName_txt.text = myGallery[i]["name"];
      
         DropDownBtn.onRollOver = function() {
            this.bg_mc.colorTo(0x10bddc, 0.2);
            this.catName_txt.colorTo(0xddfaff, 0.2);
         }
         
         DropDownBtn.onRollOut = function() {
            this.bg_mc.colorTo(0xebeeef, 3);
            this.catName_txt.colorTo(0x333333, 0.2);
         }
         
         var totalImg = myGallery[i]["image"].length;
         
         // when user clicks on one the categories, show thumbanils of that category
         DropDownBtn.total = total;
         DropDownBtn.chosenCat = i;
         DropDownBtn.onRelease = function() {
            dropDownBtn_mc.catName_txt.text = myGallery[this.chosenCat]["name"];
            activateCat(this, this.chosenCat);
            viewMode = "thumbView"; // change mode to thumb view
            showTnView(this.chosenCat, totalImg);
            
            enableCatViewBtn();
         }
         
         i++
      } else {
         delete this.onEnterFrame;
         this.removeMovieClip();
      }
   }
}
   // function determining whether to enable page buttons or not // if more than one page is needed enable the buttons
function prevBtn(counter) {
   trace(counter);
   if(counter > 1) {
      prev_btn.enabled = true;
      prev_btn.gotoAndStop(2);
      
   } else if(counter == 1) {
      prev_btn.btn_mc.icon_mc.colorTo(0x333333, 0.5);
      prev_btn.btn_mc.bg_mc.colorTo(0xffffff, 0.5);
      prev_btn.enabled = false;
      prev_btn.gotoAndStop(1);
      
      
   }
}
function nextBtn(counter, pages) {
   
   if(counter < pages) {
      next_btn.enabled = true;
      next_btn.gotoAndStop(2);
      
   } else if(counter == pages) {
      next_btn.btn_mc.icon_mc.colorTo(0x333333, 0.5);
      next_btn.btn_mc.bg_mc.colorTo(0xffffff, 0.5);
      next_btn.enabled = false;
      next_btn.gotoAndStop(1);
   }
   
}
prev_btn.onRelease = function() {
   // hide the dropdown if it's open
   if(dropDown) {
      doDropDown();
   }
   
   if(viewMode == "catView") {
      if(catPageCounter > 1) {
         catPageCounter--;
      }
      
      prevBtn(catPageCounter);
      nextBtn(catPageCounter, catNumPages);
      //trace(catPageCounter);
      
      // recaculate the start position
      var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
      //trace(pos);
      // output page status
      page_txt.text = catPageCounter+" of "+catNumPages;
      
      loadCat(pos);
   } else if(viewMode == "thumbView") {
      // hide the dropdown if it's open
      if(dropDown) {
         doDropDown();
      }
      
      
         if(thumbPageCounter > 1) {
            thumbPageCounter--;
         }
         //trace(thumbPageCounter);
         
         // recaculate the start position
         var pos = (thumbPageCounter*numThumbDisplay)-numThumbDisplay;
         
         // output page status
         page_txt.text = thumbPageCounter+" of "+thumbNumPages;
         
         // enable/disable page buttons
         prevBtn(thumbPageCounter);
         nextBtn(thumbPageCounter, thumbNumPages);
         
         remove();
         showThumbs(curCat, pos);
   }
   
}
prev_btn.onRollOver = function() {
   this.btnRollOver();
}
prev_btn.onRollOut = function() {
   this.btnRollOut();
}
next_btn.onRelease = function() {
   
   
   // hide the dropdown if it's open
   if(dropDown) {
      doDropDown();
   }
   
   
   
   if(viewMode == "catView") {
      
      trace('12313');
      
      if(catPageCounter < catNumPages) {
         catPageCounter++;
      }
      //trace(catPageCounter);
      prevBtn(catPageCounter);
      nextBtn(catPageCounter, catNumPages);
      // recaculate the start position
      var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
      //trace(pos);
      // output page status
      page_txt.text = catPageCounter+" of "+catNumPages;
      loadCat(pos);
   } else if(viewMode == "thumbView") {
      trace('aaa');
      
      // hide the dropdown if it's open
      if(dropDown) {
         doDropDown();
      }
      
      
         
         if(thumbPageCounter < thumbNumPages) {
            thumbPageCounter++;
         }
         
         // recaculate the start position
         var pos = (thumbPageCounter*numThumbDisplay)-numThumbDisplay;
         
         // output page status
         page_txt.text = thumbPageCounter+" of "+thumbNumPages;
         
         // enable/disable page buttons
         prevBtn(thumbPageCounter);
         nextBtn(thumbPageCounter, thumbNumPages);
         
         remove();
         showThumbs(curCat, pos);
   }
}
next_btn.onRollOver = function() {
   this.btnRollOver();
}
next_btn.onRollOut = function() {
   this.btnRollOut();
}
// function to initialize the category buttons
function loadCat(pos) {
      
   catWrap_mc.removeMovieClip();
   imgWrap_mc.removeMovieClip();
   
   var catWrap = _root.createEmptyMovieClip("catWrap_mc", _root.getNextHighestDepth());
   var imgWrap = _root.createEmptyMovieClip("imgWrap_mc", _root.getNextHighestDepth());
   catWrap._x = 61;
   catWrap._y = 120;
   imgWrap._x = 58;
   imgWrap._y = 120;
   
   dropDown_mc.swapDepths(_root.getNextHighestDepth());
   dropDownBtn_mc.swapDepths(_root.getNextHighestDepth());
   
   
   //get the total number of rows
   var numRows = catTotal/catCol;
   
   var xnum = catCol;
   var ynum = numRows;
   
   var xgap = catColXgap;
   var ygap = catColYgap;
   var ox = 0
   var oy = 0
   var total = xnum*ynum
   
   var i=pos;
   var j=0; // used to reset the position
   
   var taco = i+numCatDisplay;
   //trace(pos);
   
   var temp = _root.createEmptyMovieClip("temp", _root.getNextHighestDepth());
   temp.onEnterFrame = function(){
      if(i<taco && i<catTotal){
         
         //trace(i);
         var myCat = catWrap.attachMovie("cat", "cat_mc"+i, i);
         var myImg = imgWrap.attachMovie("thumb", "thumb_mc"+i, i);
         
         // mc covering thumbnails to hide dynamic text
         myImg.tnHider_mc.alphaTo(0, 3);
         
         myCat._alpha = 0;
         myImg._alpha = 0;
         myCat.alphaTo(100,3);
         myImg.alphaTo(100,3);
         
         myCat._x = Math.round(ox + (j%xnum)*(xgap + myCat._width));
         myCat._y = Math.round(oy + int(j/xnum)*ygap);
         
         myImg._x = Math.round(ox + (j%xnum)*(xgap + myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
         myImg._y = Math.round(oy + myCat._y + 25);
         
         var totalImg = myGallery[i]["image"].length;
      
         if(viewRand) {
            //get a random number between total number of images from each categories
            var RandImgNum = random(myGallery[i]["image"].length);
            var CurImage = RandImgNum;
            var ImgDate = myGallery[i]["image"][RandImgNum]["date"];
            var ImgTitle = myGallery[i]["image"][RandImgNum]["title"];
            var ImgDesc = myGallery[i]["image"][RandImgNum]["desc"];
            var ImgThumb = myGallery[i]["image"][RandImgNum]["thumb"];
            var ImgFull = myGallery[i]["image"][RandImgNum]["img"];
            
         } else {
            var CurImage = 0;
            // 0 == most recently added image <- controlled by php
            var ImgDate = myGallery[i]["image"][0]["date"];
            var ImgTitle = myGallery[i]["image"][0]["title"];
            var ImgDesc = myGallery[i]["image"][0]["desc"];
            var ImgThumb = myGallery[i]["image"][0]["thumb"];
            var ImgFull = myGallery[i]["image"][0]["img"];
         }
         
         //trace(ImgDesc);
         
         myCat.cat_txt.text = myGallery[i]["name"];
         myCat.total_txt.text = totalImg;
         
         myImg.title_txt.text =  ImgTitle;
         myImg.date_txt.text =  ImgDate;
         
         //need to send these to display thumbnails when user clicks the thumbnail from cat view
         myImg.empty_mc.total = total;
         myImg.empty_mc.curCat = i;
         
         myImg.empty_mc.curImage = CurImage;
         myImg.empty_mc.imgDesc = ImgDesc;
         myImg.empty_mc.thumbToLoad = ImgThumb;
         myImg.empty_mc.imgToLoad = ImgFull;
         myImg.empty_mc.loadThumb();
      
      
         myCat.onRollOver = function() {
            this.catBG_mc.colorTo(0x1b4d70, 0.5);
            this.cat_txt.colorTo(0xb5d9f2, 0.5);
         }
         
         myCat.onRollOut = function() {
            this.catBG_mc.colorTo(0x191919, 6);
            this.cat_txt.colorTo(0xa5a5a5, 0.5);
         }
         
         // when user clicks on one the categories, show thumbanils of that category
         myCat.total = total;
         myCat.chosenCat = i;
         myCat.onRelease = function() {
            dropDownBtn_mc.catName_txt.text = myGallery[this.chosenCat]["name"];
            activateCat(this, this.chosenCat);
            viewMode = "thumbView"; // change mode to thumb view
            showTnView(this.chosenCat, totalImg);
            
            enableCatViewBtn();
         }
         
         j++
         i++
      } else {
         delete this.onEnterFrame;
         this.removeMovieClip();
      }
   }
}
function activateCat(item, num) {
   if (currentItem != false) {
      deactivateCat(num);
   }
   
   // hide the dropdown if it's open
   if(dropDown) {
      doDropDown();
   }
   
   currentItem = item;
   currentItem.catBG_mc.colorTo(0x1b4d70, 0.5);
   currentItem.cat_txt.colorTo(0xb5d9f2, 0.5);
   
   currentItem.bg_mc.colorTo(0x10bddc, 0.2);
   currentItem.catName_txt.colorTo(0xddfaff, 0.2);
   
   /*
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].bg_mc.colorTo(0x10bddc, 0.2);
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].catName_txt.colorTo(0xddfaff, 0.2);
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].enabled = false;
   */
   currentItem.enabled = false;
}
function deactivateCat(num) {
   // for catView btns
   currentItem.catBG_mc.colorTo(0x000000,6);
   currentItem.cat_txt.colorTo(0xa5a5a5, 0.5);
   
   currentItem.bg_mc.colorTo(0xebeeef, 3);
   currentItem.catName_txt.colorTo(0x333333, 0.2);
   // for dropdown buttons
/*
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].bg_mc.colorTo(0xebeeef, 3);
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].catName_txt.colorTo(0x333333, 0.2);
   dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].enabled = true;
   */
   currentItem.enabled = true;
   currentItem = undefined;
}
MovieClip.prototype.loadThumb = function() {
   var target = this;
   var imgDesc = this.imgDesc;
   var thumbToLoad = this.thumbToLoad;
   var imgToLoad = this.imgToLoad;
   var curImage = this.curImage;
   var curCat = this.curCat;
   var thumbTotal = this.total;
   
   this.loadMovie(thumbDir+thumbToLoad);
   var temp = this._parent.createEmptyMovieClip("temp", this._parent.getNextHighestDepth());
   
   temp.onEnterFrame = function() {
      var loaded = target.getBytesLoaded();
      var total = target.getBytesTotal();
      var perc = Math.round(loaded/total*100);
      
      target._parent.bar_mc._yscale = perc;
      
      //trace(perc);
      if(perc == 100) {
         target._parent.bar_mc.alphaTo(0, 5);
         
         target.curCat = curCat;
         target.curImage = curImage;
         target.imgDesc = imgDesc;
         target.imgToLoad = imgToLoad;
         target.maxWidth = 179;
         target.maxHeight = 55;
         target.thumbTotal = thumbTotal;
         
         target.shrinkImg();
         
         delete this.onEnterFrame;
         temp.removeMovieClip();
      }
   }
}
MovieClip.prototype.shrinkImg = function (){
   
   // init pos and alpha of click_txt
   this._parent.click_txt._alpha = 100;
   //this._parent.click_txt.roundedYSlideTo(15, 0.2);
   
   var orgWidth = this._width;
   var orgHeight = this._height;
   
   var orgX = this._x;
   var orgY = this._y;
   
   // resizeImg object is returned by resizeToFit prototype function and saved as myImage;
   var myImage = this.resizeToFit();
   this.tween(["_width", "_height"], [myImage.newWidth, myImage.newHeight], 1);
   // slide the image to the middle point y
   var yMiddle = -(Number(myImage.newHeight/2)-40);
   //trace(yMiddle);
   //this.ySlideTo(yMiddle, 2);
   
   
   this.onRollOver = function() {
      //this._parent.click_txt.alphaTo(100, 2);
      this._parent.click_txt.roundedYSlideTo(-8, 1);
      // make it dark
      this._parent.rollover_mc.alphaTo(70, 0.5);
      //this.tween(["_width", "_height"], [myImage.newWidth+20, myImage.newHeight+20], 2);
      //this.colorTransformTo(200, 0, 200, 0, 200, 0, 200, 0, 0.3, "linear");
      //this.colorTransformTo(100, 0, 100, 0, 100, 0, 100, 0, 1, "linear", 0.3);
   }
   this.onRollOut = function() {
      //this._parent.click_txt.alphaTo(0, 2);
      this._parent.click_txt.roundedYSlideTo(-24.6, 1);
      this._parent.rollover_mc.alphaTo(0, 3);
      //this.tween(["_width", "_height"], [myImage.newWidth, myImage.newHeight], 2);
   }
   this.onRelease = function()  {
      
      // hide the dropdown if it's open
      if(dropDown) {
         doDropDown();
      }
      
      // reset current image to this image user just clicked on
      _root.curImage = this.curImage;
      // reset the category
      _root.curCat = this.curCat;
      
      this._parent.rollover_mc.alphaTo(90, 0.5);
      //this._parent.viewing_mc.alphaTo(100, 6);
      this._parent.click_txt.roundedYSlideTo(-24.6, 1);
      
      //activateItem(this, myImage.newWidth, myImage.newHeight);
      
      
      // view the image in full scale
      showFullImage(this.imgToLoad, this.imgDesc);
   
   }
}
// TIMER FUNCTION
function loadTimer() {
   var speed = defTranSpeed;
   //var timer = _root.attachMovie("timer", "timer_mc", _root.getNextHighestDepth());
   //timer._x = 474;
   //timer._y = 15;
   myTimer = new Timer();
   myTimer.setDelay(5);
   myTimer.setAlarm(speed);
   var obj = new Object;
   myTimer.addListener(obj);
   
   //reset the timer
   myTimer.reset();
   
   obj.onTimerStart = function(t){
      //trace("Starting countdown::\n" + myTimer.getAlarm());
   }
   obj.onTimerTick = function(t){
      
      //trace(myTimer.getAlarm() - t);
      var curTime = myTimer.getAlarm() - t;
      //trace(curTime);
      
      var curScale = -Math.round((((curTime * 100)/speed) - 100));
      timer_mc.bar_mc._xscale = curScale;
      timer_mc.bar_mc._alpha = 50;
      /*
      // caculate degrees relative to seconds
      // caculate 0 to 360
      var curDegree = - Math.round((((curTime * 360)/speed) - 360));
      //reset rotation
      timer.lhalf_mc._rotation = 0;
      if(curDegree < 180) {
         timer.fhalf_mc._rotation = curDegree + 180;
      }
      if(curDegree >= 180) {
         timer.lhalf_mc._rotation = curDegree + 180;
      }
      */
   }
   obj.onTimerAlarm = function(){
      //trace("Time is up!");
      
      //total of images in chosen category
      var totalImages = myGallery[curCat]["image"].length;
      
      // update the counter and load the news using counter
      if(curImage == totalImages) { // after last one go back to first image
         curImage = 0;
      }
      if(curImage < totalImages-1) {
         showNextImage();
      } else {
         curImage = -1;
         showNextImage();
      }
      //trace(curImage);
      
      // reset the timer so it loops
      myTimer.reset();
   }
   
   myTimer.start();
   
   slideshow_mc.onRelease = function() {
      timerToggle();
   }
}
function showFullImage(imgToLoad, desc) { //<--------------------------------------------------------- SHOW FULL IMAGE // START FROM HERE...
   // reset the conditions
   transBG_mc._x = 34;
   transBG_mc._y = 34;
   transBG_mc._visible = true;
   transBG_mc.alphaTo(100, 1);
   transBG_mc.mask_mc._alpha = 0;
   transBG_mc.swapDepths(_root.getNextHighestDepth());
   transBG_mc.fake_btn.enabled = false;
   transBG_mc.mask_mc.alphaTo(100, 0.7, undefined, 0, 
      function() {
         //load preloader
         var myPreloader = transBG_mc.attachMovie("imagePreloader", "preloader_mc", this.getNextHighestDepth());
         myPreloader._alpha = 0;
         myPreloader.alphaTo(100, 1);
         myPreloader._x = transBG_mc._width/2;
         myPreloader._y = transBG_mc._height/2-20;
         loadFull(imgToLoad, desc);
      }
   );
   
   /*
   transBG_mc.exit_mc.onRelease = function() {
      transBG_mc.slideTo(34, -900, 0.1);
   }
   */
}
function loadFull(imgToLoad, desc) {
   var holder = transBG_mc.picBG_mc.empty_mc;
   
   holder._alpha = 0;
   holder.loadMovie(imageDir+imgToLoad);
   
   var temp = holder._parent.createEmptyMovieClip("temp", holder._parent.getNextHighestDepth());
   
   temp.onEnterFrame = function() {
      var loaded = holder.getBytesLoaded();
      var total = holder.getBytesTotal();
      var perc = Math.round((loaded/total)*100);
      
      //trace(perc);
      
      if(perc == 100) {
         // hide the preloader
         transBG_mc.preloader_mc.alphaTo(0, 1, "linear", 0, function() { transBG_mc.prealoder_mc.removeMovieClip(); });
         //trace(holder._width);
         checkImageWidth(holder, desc);
         
         delete this.onEnterFrame;
         temp.removeMovieClip();
      }
   }
}
function checkImageWidth(holder, desc) {
   var temp = holder._parent.createEmptyMovieClip("temp", holder._parent.getNextHighestDepth());
   temp.onEnterFrame = function() {
      if(holder._width > 0) {
         //trace(holder._width);
         displayFullImage(holder, desc);
         // start the timer
         if(autoSlide) {
            loadTimer();
         }
         delete this.onEnterFrame;
         temp.removeMovieClip();
      }
   }
}
function timerToggle() {
   if(autoSlide) {
      slideshow_mc.gotoAndStop(2);
      myTimer.pause();
      autoSlide = false;
   } else {
      slideshow_mc.gotoAndStop(3);
      myTimer.resume();
      autoSlide = true;
   }
}
function displayFullImage(imageHolder, desc) {
   
   var imageBorder = 20;
   var mcW = imageHolder._width;
   var mcH = imageHolder._height;
   
   
   //total of images in chosen category
   var totalImages = myGallery[curCat]["image"].length;
   curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
   enableImageNav(true);
   //trace(mcW);
   
   if(mcW > 710) {
      imageHolder.maxWidth = 710;
      var newSize = imageHolder.resizeToFit();
      imageHolder.tween(["_width", "_height"], [newSize.newWidth, newSize.newHeight], 0.5, undefined);
      var mcW = newSize.newWidth;
      var mcH = newSize.newHeight;
   }
   
   var xCenter = (transBG_mc.fake_btn._width/2) - (Number(mcW+imageBorder)/2);
   var yCenter = (transBG_mc.fake_btn._height/2) - (Number(mcH+imageBorder)/2);
   
   // center the image
   transBG_mc.picBG_mc.slideTo(xCenter, yCenter, 0.5);
   // resize the background
   transBG_mc.picBG_mc.bg_mc.tween(["_width", "_height"], [mcW+imageBorder, mcH+imageBorder], 0.5, undefined, 0, function() {  });
   transBG_mc.picBG_mc.bg_mc.alphaTo(100, 0.5, "linear", 0, function() { imageHolder.alphaTo(100, 2); });
   
   var descMC = _root.transBG_mc.desc_mc;
   
   // put description
   descMC.desc_txt.text = desc;
   
   
   // resize textfield
   var padding = 30;
   var myFormat_fmt = new TextFormat();
   var textDimension = myFormat_fmt.getTextExtent(desc, 200);
   var tWidth = textDimension.textFieldWidth;
   var tHeight = textDimension.textFieldHeight+20; // used 20 to prevent it from text get cut off at the end //////////////////////////
   
   descMC.desc_txt._width = tWidth;
   descMC.desc_txt._height = tHeight;
   // reposition textfield
   descMC.desc_txt._x = padding/2;
   descMC.desc_txt._y = padding/2;
   descMC.descBG_mc._width = tWidth+padding;
   descMC.descBG_mc._height = tHeight+padding;
   descMC._alpha = 0;
   
   imageHolder.onRollOver = function() {
      descMC.alphaTo(100,1);
   }
   imageHolder.onRollOut = function() {
      descMC.alphaTo(0,1);
   }
   
   // center image description mc
   var xDescCenter = ((transBG_mc.fake_btn._width+imageBorder)/2) - ((descMC._width+imageBorder)/2);
   var yDescCenter = ((transBG_mc.fake_btn._height+imageBorder)/2) - ((descMC._height+imageBorder)/2);
   
   descMC.slideTo(xDescCenter, yDescCenter, 0.5);
   
   // hide full view
   exit_mc.onRelease = function() {
      var DisappearW = mcW;
      var DisappearH = mcH;
      var DisappearXCenter = (transBG_mc.fake_btn._width/2) - (Number(DisappearW+imageBorder/2)/2);
      var DisappearYCenter = (transBG_mc.fake_btn._height/2) - (Number(DisappearH+imageBorder/2)/2);
      
      imageHolder.alphaTo(0, 0.2, "linear", 0, function() { imageHolder.unloadMovie() });
      //transBG_mc.picBG_mc.slideTo(DisappearXCenter, DisappearYCenter, 0.5, undefined, 0.5);
      //transBG_mc.picBG_mc.bg_mc.tween(["_width", "_height"], [DisappearW, DisappearH], 0.5, undefined, 0.5);
      transBG_mc.picBG_mc.bg_mc.alphaTo(0, 0.5, "linear", undefined);
      transBG_mc.alphaTo(0, 0.5, "linear", undefined, function() { transBG_mc._visible = false;});
      
      
      // disable image nav 
      enableImageNav(false);
      
      this.btnRollOut();
      
      // stop the timer
      myTimer.pause();
   
   }
   exit_mc.onRollOver = function() {
      this.btnRollOver();
   }
   exit_mc.onRollOut = function() {
      this.btnRollOut();
   }
   
   next_mc.onRelease = function() {
      // turn off timer only if autoSlide is true
      if(autoSlide) {
         timerToggle();
      }
      showNextImage(imageHolder);
   }
   next_mc.onRollOver = function() {
      this.btnRollOver();
   }
   next_mc.onRollOut = function() {
      this.btnRollOut();
   }
   
   prev_mc.onRelease = function() {
      // turn off timer only if autoSlide is true
      if(autoSlide) {
         timerToggle();
      }
      showPrevImage(imageHolder);
   }
   prev_mc.onRollOver = function() {
      this.btnRollOver();
   }
   prev_mc.onRollOut = function() {
      this.btnRollOut();
   }
   
   slideshow_mc.onRelease = function() {
      timerToggle();
   }
   slideshow_mc.onRollOver = function() {
      if(!autoSlide) {
         this.btnRollOver();
      }
   }
   slideshow_mc.onRollOut = function() {
      this.btnRollOut();
   }
   
}
MovieClip.prototype.btnRollOver = function() {
   this.btn_mc.bg_mc.colorTo(0x333333, 0.1);
   this.btn_mc.icon_mc.colorTo(0xffffff, 0.1);
}
MovieClip.prototype.btnRollOut = function() {
   this.btn_mc.bg_mc.colorTo(0xffffff, 0.1);
   this.btn_mc.icon_mc.colorTo(0x333333, 0.1);
}
// enable image navigation buttons
function enableImageNav(showNav) {
   if(showNav) {
      if(autoSlide) {
         slideshow_mc.gotoAndStop(3);
      } else {
         slideshow_mc.gotoAndStop(2);
      } 
      next_mc.gotoAndStop(2);
      prev_mc.gotoAndStop(2);
      exit_mc.gotoAndStop(2);
      curImage_txt.colorTo(0x333333, 0.5);
      slideshow_mc.enabled = true;
      next_mc.enabled = true;
      prev_mc.enabled = true;
      exit_mc.enabled = true;
      
   } else {
      slideshow_mc.gotoAndStop(1);
      next_mc.gotoAndStop(1);
      prev_mc.gotoAndStop(1);
      exit_mc.gotoAndStop(1);
      curImage_txt.colorTo(0xcccccc, 0.5);
      slideshow_mc.enabled = false;
      next_mc.enabled = false;
      prev_mc.enabled = false;
      exit_mc.enabled = false;
   }
}
function showNextImage(imageHolder) {
   //total of images in chosen category
   var totalImages = myGallery[curCat]["image"].length;
   if(totalImages-1 > curImage) {
      
      _root.curImage += 1;
   } else if(totalImages-1 == curImage) {
      
      _root.curImage = 0;
      
   }
   
   //fade the picture out
   imageHolder.alphaTo(0, 0.5, "linear");
   var ImgDesc = myGallery[curCat]["image"][curImage]["desc"];
   var ImgFull = myGallery[curCat]["image"][curImage]["img"];
   
   /*
   // disable thumb
   var thumb = imgWrap_mc["thumb_mc"+curImage];
   activateItem(thumb);*/
   
   curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
   showFullImage(ImgFull, ImgDesc);
   
}
function showPrevImage(imageHolder) {
   //total of images in chosen category
   var totalImages = myGallery[curCat]["image"].length;
   if(curImage > 0) {
      
      _root.curImage -= 1;
   } else if(curImage == 0) {
      
      _root.curImage = totalImages-1;
      
   }
   
   //fade the picture out
   imageHolder.alphaTo(0, 0.5, "linear");
   var ImgDesc = myGallery[curCat]["image"][curImage]["desc"];
   var ImgFull = myGallery[curCat]["image"][curImage]["img"];
      
   curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
   showFullImage(ImgFull, ImgDesc);
   
}
function activateItem(item, oWidth, oHeight) {
   // hide the dropdown if it's open
   if(dropDown) {
      doDropDown();
   }
   
   if (currentItem != false) {
      deactivateItem();
   }
   currentItem = item;
   currentItem.oWidth = oWidth;
   currentItem.oHeight = oHeight;
   currentItem.enabled = false;
}
 
function deactivateItem() {
   currentItem.tween(["_width", "_height"], [currentItem.oWidth, currentItem.oHeight], 2);
   currentItem._parent.viewing_mc.alphaTo(0, 1);
   currentItem._parent.rollover_mc.alphaTo(0, 3);
   currentItem.enabled = true;
   currentItem = undefined;
}
/* prototype for resizing an image to defined size while keeping ratio */
/* it returns an object with new width and height */
MovieClip.prototype.resizeToFit = function (){
   var pMaxWidth = this.maxWidth;
   var pMaxHeight = this.maxHeight;
   
   // determines ratio depends on the width and height
   //this._width>=this._height ? ratio=pMaxWidth/this._width : ratio=pMaxHeight/this._height;
   
   // ratio based on width
   var ratio=pMaxWidth/this._width;
   var resizedImg = new Object();
   resizedImg.newWidth = Math.round(this._width*ratio);
   resizedImg.newHeight = Math.round(this._height*ratio);
   
   return resizedImg;
}
function showTnView(catNum, totalImg) {
   viewMode = "thumbView";
   curCat = catNum;
   
   
   // determine the number of pages needed for viewing thumbnails
   if(totalImg > numThumbDisplay) {
      trace('true');
      thumbNumPages = Math.ceil(totalImg/numThumbDisplay);
      
   } else {
      trace('false');
      // if categories are less than the limit only one page is needed
      thumbNumPages = 1;
   }
   // start from first page
   thumbPageCounter = 1;
         
   // start from 0;
   var pos = 0;
   
   // output page status
   page_txt.text = thumbPageCounter+" of "+thumbNumPages;
   
   // initialize
   prevBtn(thumbPageCounter);
   nextBtn(thumbPageCounter, thumbNumPages);
   
   remove();
   showThumbs(catNum, pos);
   
}
   
function remove() {
   hideCat();
   /*
   // count how many thumbnails are currently sitting inside of imgWrap_mc
   var count = 0;
   for(var each in imgWrap_mc) {
      count++;
   }
   trace(count);
   
   var i=0;
   var temp = _root.createEmptyMovieClip("temp", _root.getNextHighestDepth());
   temp.onEnterFrame = function(){
      if(i<count){
         imgWrap_mc["thumb_mc"+i].tnHider_mc.alphaTo(100, 1, undefined, 0, function() { this._parent.removeMovieClip() });
         //catWrap_mc["cat_mc"+i].alphaTo(0, 1, undefined, 0, function() { });
         //imgWrap_mc["thumb_mc"+i].alphaTo(0, 1, undefined, 0, function() { this.removeMovieClip() });
         
         i++
      } else {
         hideCat();
         delete this.onEnterFrame;
      }
   }
   */
}
function hideCat() {
   for(var i=0; i<catTotal; i++) {
      var eachCat = catWrap_mc["cat_mc"+i];
      
      //eachCat.tween("_x", 0, 1);
      //eachCat.tween("_y", Math.round(Number(eachCat._height+1) *i), 1);
      eachCat._visible = false;
   }
}
function showThumbs(catNum, pos) {
   
   imgWrap_mc.removeMovieClip();
   var imgWrap = _root.createEmptyMovieClip("imgWrap_mc", _root.getNextHighestDepth());
   imgWrap._x = 58;
   imgWrap._y = 120;
   
   dropDown_mc.swapDepths(_root.getNextHighestDepth());
   dropDownBtn_mc.swapDepths(_root.getNextHighestDepth());
   
   var total;
   var totalThumbs = myGallery[catNum]["image"].length;
   var numRows = totalThumbs/catCol;
   
   var xnum = catCol;
   var ynum = numRows;
   var xgap = catColXgap;
   var ygap = catColYgap-28;
   var ox = 0
   var oy = 0
   
   var total = xnum*ynum
   
   var i=pos;
   var j=0; // used to reset the position
   var taco = i+numThumbDisplay;
   
   var temp = _root.createEmptyMovieClip("temp", _root.getNextHighestDepth());
   temp.onEnterFrame = function(){
      
      if(i<taco && i<totalThumbs){
         //trace(i);
         var myImg = imgWrap_mc.attachMovie("thumb", "thumb_mc"+i, i);
         
         myImg._alpha = 0;
         myImg.alphaTo(100, 3);
         myImg.tnHider_mc.alphaTo(0, 3);
         myImg._x = Math.round(ox + (j%xnum)*(xgap + myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
         myImg._y = Math.round(oy + int(j/xnum)*ygap);
         var ImgDate = myGallery[catNum]["image"][i]["date"];
         var ImgTitle = myGallery[catNum]["image"][i]["title"];
         var ImgDesc = myGallery[catNum]["image"][i]["desc"];
         var ImgThumb = myGallery[catNum]["image"][i]["thumb"];
         var ImgFull = myGallery[catNum]["image"][i]["img"];
         
         myImg.title_txt.text =  ImgTitle;
         myImg.date_txt.text =  ImgDate;
         
         myImg.empty_mc.curCat = catNum;
         myImg.empty_mc.curImage = i;
         myImg.empty_mc.imgDesc = ImgDesc;
         myImg.empty_mc.imgToLoad = ImgFull;
         myImg.empty_mc.thumbToLoad = ImgThumb;
         myImg.empty_mc.loadThumb();
      
         j++;
         i++;
      } else {
         delete this.onEnterFrame;
         this.removeMovieClip();
      }
   }
} // end of showThumbs()
   
dropDownBtn_mc.onRelease = function() {
   doDropDown();
}
function doDropDown() {
   if(!dropDown) {
      dropDown_mc.ySlideTo(68, 0.8, "easeOutExpo");
      dropDown = true;
   } else {
      dropDown_mc.ySlideTo(-120, 0.8, "easeOutExpo");
      dropDown = false;
   }
}
dropDown_mc.mask_mc.onEnterFrame = function() {
   
   //only if btns exceed
   if(dropDown_mc.bg_mc.hitTest(_root._xmouse, _root._ymouse, true) && this._parent.catBtn_mc._height > this._height) {
      ymin = this._y+this._height-this._parent.catBtn_mc._height;
      ymax = this._y;
      conv = (this._ymouse-15)*1.3/this._height;
      conv>1 ? conv=1 : null;
      conv<0 ? conv=0 : null;
      this._parent.catBtn_mc.ySlideTo(Math.round(ymax - conv*(ymax-ymin)), 1); 
   }
}
dropDown_mc._y = -120;
dropDown_mc.catBtn_mc.setMask(dropDown_mc.mask_mc);
dropDown_mc.setMask(dropMask_mc);
					

 
  
			 
    
 