Transitions Between External SWFs Tutorial

Hi Voetsjoeba

Thanks very much for your informative and clear tutorial on transitions between external swfs.

http://www.kirupa.com/developer/mx2004/transitions.htm

I followed the tutorial and everything works great till I had more actionscripts on one of my external swfs (scripts extracted from an existing photo gallery sample). Something in there is conflicting with the transitions scripts, which I’m tearing my hair out trying to find out what still.

I suspect its got to do with getNextHighestDepth, as I have quite a few of these going on in the photo gallery.

I’ve included my scripts for the photo gallery as below.

Would appreciate greatly your help in this. Many thanks in advance!

Regards,
Damian

========================================

/*
Image Gallery V1.0
Created April 2, 2006
Created by Tony Yoo
Email: info@tonyyoo.com
Website: tonyyoo.com

  • Please keep this information intact
  • Please feel free to modify the script and the look of the gallery to meet your needs.
  • And make sure you let me know where this gallery gets used.
  • My scripts aren’t so organized at this point so you may find it difficult to make customization. If you have any questions regarding this gallery please contact me using the eamil address above.
    */
    this._lockroot = true;

//stop();
var yDropSlide = 156.5;
//var yDropSlide = 0;

// include assets
#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 = false; // on/off random preview
var catCol = 3; // number of columns for category
var numCatDisplay = 3; // max number of categories to show per page
var numThumbDisplay = 3; // max number of thumbnails to show per page
var catColXgap = 4; // gap between categories
var catColYgap = 168;
var dropDown = false;

var curImage = 0;
var curCat = 0;

// slideshow switch
var autoSlide = true;
// default transition speed
var defTranSpeed = 150;

catView_btn._alpha = 0;

// load the xml data

gallery = new XMLSA();
gallery.load(“archives.xml”);
gallery.onLoad = function(ok){
if (ok) {
parseXml();
} else {

}

}

function parseXml()

{ 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* = new Array();
    myGallery*["name"] = gallery.category*.attributes.name;
    myGallery*["image"] = new Array();
    
    var imageCount = gallery.category*.image.length;
    for(var k=0; k<imageCount; k++) { //looping through images
        myGallery*["image"][k] = new Array();
        myGallery*["image"][k]["date"] = gallery.category*.image[k].date.getValue();
        myGallery*["image"][k]["title"] = gallery.category*.image[k].title.getValue();
        myGallery*["image"][k]["desc"] = gallery.category*.image[k].desc.getValue();
        myGallery*["image"][k]["thumb"] = gallery.category*.image[k].thumb.getValue();
        myGallery*["image"][k]["img"] = gallery.category*.image[k].img.getValue();
    }
}


// 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 Project";
    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){
        
        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*["name"];
    
        DropDownBtn.onRollOver = function() {
            this.bg_mc.colorTo(0xFF9900, 0.2);
            this.catName_txt.colorTo(0xFFFFFF, 0.2);
        }
        
        DropDownBtn.onRollOut = function() {
            this.bg_mc.colorTo(0xebeeef, 3);
            this.catName_txt.colorTo(0x333333, 0.2);
        }
        
        var totalImg = myGallery*["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) {

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);
    
    // recaculate the start position
    var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
    
    // 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--;
        }
        
        // 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") {
    
    
    if(catPageCounter < catNumPages) {
        catPageCounter++;
    }
    
    prevBtn(catPageCounter);
    nextBtn(catPageCounter, catNumPages);
    // recaculate the start position
    var pos = (catPageCounter*numCatDisplay)-numCatDisplay;

    // 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 < 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._x = 225;
catWrap._y = 0;
//imgWrap._x = 58;

/* TO MOVE THE WHOLE GROUP OF IMAGES */

// imgWrap._x = 163;
// imgWrap._y = 340;
imgWrap._x = 475;
imgWrap._y = 115;

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;


var temp = _root.createEmptyMovieClip("temp", _root.getNextHighestDepth());
temp.onEnterFrame = function(){
    if(i<taco && i<catTotal){
        
        
        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*["image"].length;
    
        if(viewRand) {
            //get a random number between total number of images from each categories
            var RandImgNum = random(myGallery*["image"].length);
            var CurImage = RandImgNum;
            var ImgDate = myGallery*["image"][RandImgNum]["date"];
            var ImgTitle = myGallery*["image"][RandImgNum]["title"];
            var ImgDesc = myGallery*["image"][RandImgNum]["desc"];
            var ImgThumb = myGallery*["image"][RandImgNum]["thumb"];
            var ImgFull = myGallery*["image"][RandImgNum]["img"];
            
        } else {
            var CurImage = 0;
            // 0 == most recently added image <- controlled by php
            var ImgDate = myGallery*["image"][0]["date"];
            var ImgTitle = myGallery*["image"][0]["title"];
            var ImgDesc = myGallery*["image"][0]["desc"];
            var ImgThumb = myGallery*["image"][0]["thumb"];
            var ImgFull = myGallery*["image"][0]["img"];
        }
        
        
        myCat.cat_txt.text = myGallery*["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.total = total;
        myCat.chosenCat = i;
        
        
        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(0x333333, 0.5);
currentItem.cat_txt.colorTo(0xb5d9f2, 0.5);

currentItem.bg_mc.colorTo(0xEEEEEE, 0.2);
currentItem.catName_txt.colorTo(0xddfaff, 0.2);


currentItem.enabled = false;

}

function deactivateCat(num) {

// for catView btns
currentItem.catBG_mc.colorTo(0x191919, 6);
currentItem.cat_txt.colorTo(0xa5a5a5, 0.5);

currentItem.bg_mc.colorTo(0xebeeef, 3);
currentItem.catName_txt.colorTo(0x333333, 0.2);
// for dropdown buttons

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;
    
    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);

//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.onRollOut = function() {
    this._parent.click_txt.roundedYSlideTo(-24.6, 1);
    this._parent.rollover_mc.alphaTo(0, 3);
}

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){
    
}
obj.onTimerTick = function(t){
    

    var curTime = myTimer.getAlarm() - t;

    
    var curScale = -Math.round((((curTime * 100)/speed) - 100));
    timer_mc.bar_mc._xscale = curScale;
    timer_mc.bar_mc._alpha = 50;

}
obj.onTimerAlarm = function(){
    
    //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();
    }
    
    // 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 = 146;
transBG_mc._x = 11.9;
transBG_mc._y = 11.1;
transBG_mc._visible = true;
transBG_mc.alphaTo(100, 1);
transBG_mc.mask_mc._alpha = 0;

transBG_mc.swapDepths(_root.getNextHighestDepth());
this.prev_mc.swapDepths(_root.getNextHighestDepth());
this.next_mc.swapDepths(_root.getNextHighestDepth());
this.slideshow_mc.swapDepths(_root.getNextHighestDepth());
this.exit_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.preloader_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 &gt; 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)/1.70);
var yCenter = (transBG_mc.fake_btn._height/2) - (Number(mcH+imageBorder)/1.35);

// 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
curProj_txt.text = 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.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);
timer_mc.alphaTo(100, 0.5);
dot_mc.alphaTo(100, 0.5);
curImage_txt.alphaTo(100, 0.5);
curProj_txt.alphaTo(100, 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);
    timer_mc.alphaTo(0, 0.5);
    dot_mc.alphaTo(0, 0.5);
    curImage_txt.alphaTo(0, 0.5);
    curProj_txt.alphaTo(0, 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"];


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;
}

MovieClip.prototype.resizeToFit = function (){

var pMaxWidth = this.maxWidth;
var pMaxHeight = this.maxHeight;


// 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 &gt; 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();

}

function hideCat() {
for(var i=0; i<catTotal; i++) {
var eachCat = catWrap_mc[“cat_mc”+i];

    eachCat._visible = false;
}

}

function showThumbs(catNum, pos) {

imgWrap_mc.removeMovieClip();
var imgWrap = _root.createEmptyMovieClip("imgWrap_mc", _root.getNextHighestDepth());


imgWrap._x = 222;
imgWrap._y = 0;

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&lt;taco && i&lt;totalThumbs){
    
        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"]*["date"];
        var ImgTitle = myGallery[catNum]["image"]*["title"];
        var ImgDesc = myGallery[catNum]["image"]*["desc"];
        var ImgThumb = myGallery[catNum]["image"]*["thumb"];
        var ImgFull = myGallery[catNum]["image"]*["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(yDropSlide, 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 &gt; this._height) {
    ymin = this._y+this._height-this._parent.catBtn_mc._height;
    ymax = this._y;
    conv = (this._ymouse-15)*1.3/this._height;
    conv&gt;1 ? conv=1 : null;
    conv&lt;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);

========================================