# Fade out old movieclip, fade in new one

**URL:** https://forum.kirupa.com/t/fade-out-old-movieclip-fade-in-new-one/253433
**Category:** Uncategorized
**Created:** [March 1, 2008, 2:43am UTC](https://forum.kirupa.com/t/fade-out-old-movieclip-fade-in-new-one/253433 "2008-03-01T02:43:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jimp](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jimp/32/1747_2.png) [@Jimp](https://forum.kirupa.com/u/Jimp)
#### Post date: [March 1, 2008, 2:43am UTC](https://forum.kirupa.com/t/fade-out-old-movieclip-fade-in-new-one/253433/1 "2008-03-01T02:43:26Z")

</div>

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:

```auto

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!🙂
