# My actionScript only works half the time - animate on/off

**URL:** <https://forum.kirupa.com/t/my-actionscript-only-works-half-the-time-animate-on-off/269701>\
**Category:** flash\
**Created:** [August 31, 2008, 2:49am UTC](https://forum.kirupa.com/t/my-actionscript-only-works-half-the-time-animate-on-off/269701 "2008-08-31T02:49:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dango](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@dango](https://forum.kirupa.com/u/dango)\
**Post date:** [August 31, 2008, 2:49am UTC](https://forum.kirupa.com/t/my-actionscript-only-works-half-the-time-animate-on-off/269701/1 "2008-08-31T02:49:06Z")

</div>

hello,

i have a basic formula i use on most websites that i make. the current site i am making is not working properly. when i open a new page, the current page does not always animate off. sometimes it does, but 50% of the time it does not. this is freaking me out big time. does anyone know why this might be happening?

my code

```auto
var currentPage = "contentHome_mc";
_root.onLoad = function() {
    animateOn("contentHome_mc");
};
function animateOn(page:String) {
    eval(page).gotoAndPlay("on");
}
function animateOff(page:String) {
    eval(page).gotoAndPlay("off");
}
home_mc.onRelease = function() {
    if (currentPage != "contentHome_mc") {
        animateOff(currentPage);
        animateOn("contentHome_mc");
        currentPage = "contentHome_mc";
    }
};
services_mc.onRelease = function() {
    if (currentPage != "contentServices_mc") {
        animateOff(currentPage);
        animateOn("contentServices_mc");
        currentPage = "contentServices_mc";
    }
};
gardens_mc.onRelease = function() {
    if (currentPage != "contentGardens_mc") {
        animateOff(currentPage);
        animateOn("contentGardens_mc");
        currentPage = "contentGardens_mc";
    }
};
design_mc.onRelease = function() {
    if (currentPage != "contentDesign_mc") {
        animateOff(currentPage);
        animateOn("contentDesign_mc");
        currentPage = "contentDesign_mc";
    }
};
contact_mc.onRelease = function() {
    if (currentPage != "contentContact_mc") {
        animateOff(currentPage);
        animateOn("contentContact_mc");
        currentPage = "contentContact_mc";
    }
};

```

any help is greatly appreciated. i am using the exact same code on a different site and it works fine. and because it works half the time on this problematic site, i know all my instance names are correct. so what gives?
