# \[Flash CS5\] Actionscript 2

**URL:** <https://forum.kirupa.com/t/flash-cs5-actionscript-2/313515>\
**Category:** flash\
**Created:** [September 1, 2010, 4:55pm UTC](https://forum.kirupa.com/t/flash-cs5-actionscript-2/313515 "2010-09-01T16:55:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![infyx](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@infyx](https://forum.kirupa.com/u/infyx)\
**Post date:** [September 1, 2010, 4:55pm UTC](https://forum.kirupa.com/t/flash-cs5-actionscript-2/313515/1 "2010-09-01T16:55:10Z")

</div>

hello,

im working on this project and i’ve encountered a problem:  
i have an array that includes all the frame labels that i want the array to jump to and this code for the buttons

```auto
next_btn.onRelease = function() {     
    if (currentLabel < labelArr.length - 1) {         
        currentLabel++;         
        gotoAndPlay(labelArr[currentLabel]);     
    }else{                 
        currentLabel = 0;         
        gotoAndStop(labelArr[currentLabel]);
    } 
}

```

ive reached a point now that i have a movie clip on root and i want when an animation ends inside the movie clip to run this code

```auto
function() {     
    if (currentLabel < labelArr.length - 1) {         
        currentLabel++;         
        gotoAndPlay(labelArr[currentLabel]);     
    }else{                 
        currentLabel = 0;         
        gotoAndStop(labelArr[currentLabel]);
    } 
}

```

ive tried this

```auto
this.onEnterFrame = function() {
if (currentLabel < labelArr.length - 1) { 
        currentLabel++;         
        gotoAndPlay(labelArr[_root.currentLabel]); 
    }else{                  
        currentLabel = 0;         
        gotoAndStop(labelArr[currentLabel]);
    } 
}

```

but it doesn’t work and i don’t know why. im guessing that there is something to do with the script being inside the movie clip (\_root.fan\_mc) but i don’t know how to reformat it for it to work.

any ideas?
