setInterval(); in AS

I have 5 different images in 5 different frames, and i need animate them like a slider.

I build this code:

function playNextFrame(){
        if(_root._currentframe+1 == 7) {
            gotoAndStop(2);
        }else{
            gotoAndStop(_currentframe+1);
        }
}

 var myTimer = setInterval(playNextFrame, 5000);

But when I click in the navigations buttons (per example)

but1.onRelease = function() {
    gotoAndStop(2);
};

it goes to random frames at random times :/

If you can help me with fade effects, would also be of great help. ^^

Upvotes: 1

Views: 155

Answers (1)

Paul Bainbridge
Paul Bainbridge

Reputation: 46

When you click on the button you will also need to clear the interval so that it no longer fires. This is what causes your random frame jumps probably.

but1.onRelease = function() {
clearInterval(myTimer)
gotoAndStop(2);};

Upvotes: 2

Related Questions