Fade out old movieclip, fade in new one

Ok so im having trouble with this. Ive been using flash for years (for animation) but ive only just started properly looking at actionscript.

What Im doing is making a flash site, in which when you click a menu item the current page fades out, the new one fades in. Havng a few problems so far though!

Here is what I have:



var selectedPage = "home";

//attach home page
holder.attachMovie("home","selectedPage","1");

//load new page function
function loadPage(pageName) {
    selectedPage = pageName;
    holder.onEnterFrame = function() {

        //fade out old page
        alphaDifference = Math.abs(holder._alpha-0);
        if (holder._alpha>0) {
            holder._alpha -= alphaDifference/6;
            //end of fade

            //if the alpha of the old page is 0, load new page
        } else if (holder._alpha == 0) {
            holder.attachMovie("pageName","selectedPage","1");
        }
        //fade in the new page 
        if (holder._alpha<0) {
            holder._alpha += alphaDifference/6;
        } else if (holder._alpha == 100) {
            delete holder.onEnterFrame;
        }
    };
}

menu.homeButton.onRelease = function() {
    loadPage(home);
};


It works to the point of loading the home page, and then fading that out when i click a new item on the menu, but it doesnt seem to be loading a newpage in or fading back in.

Any help would be greatly appriciated, if you need me to explain how it works (or not work) i will!:slight_smile: