Repeating a line of code or infinate prevFrame

Hey,

I’m trying to create a movie clip that can be controlled to move a shape left or right (as animated in the movie clip) via buttons on the main stage.

I was thinking I could just add prevFrame or nextFrame to the controlling buttons when the mouse rolls over them… like this:

[LEFT]

on (rollOver) {
    this.shape.prevFrame();
}

[/LEFT]

[FONT=monospace]
[/FONT]But now I need a method of repeating it non-stop while you are on the button. Can I loop the prevFrame infinatly or loop that line of code? Any ideas?

P.S I’m just getting to grips with actionscript and I’m hitting a few hurdles on the way, so please excuse my ignorance.

Al

The answer is right under your nose, a few threads lower down:

cheers mate, I’m almost there :slight_smile:

…Just one question. If the buttons are controlling a movie clip with the instance name “shape”, how would I control that? I’ve tried changing the code you suggested (as seen below) but my action script isn’t quite there yet :frowning:

[COLOR=#808080]*// place this code on your main timeline*[/COLOR]
[LEFT] rewind = [COLOR=#000000]**false**[/COLOR];
[COLOR=#0000ff]onEnterFrame[/COLOR] = [COLOR=#000000]**function**[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]_currentframe[/COLOR] > [COLOR=#000080]1[/COLOR] && rewind[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]prevFrame[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#0000ff]play[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
[COLOR=#808080]*// place this code on your rewind arrow*[/COLOR]
[COLOR=#0000ff]on[/COLOR] [COLOR=#000000]([/COLOR]press[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]rewind[/COLOR] = [COLOR=#000000]**true**[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000ff]on[/COLOR] [COLOR=#000000]([/COLOR]release[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]rewind[/COLOR] = [COLOR=#000000]**false**[/COLOR];
[COLOR=#000000]}[/COLOR] 

[/LEFT]

The code I’m using for the forward button is as follows and I’m quite happy with that one, basically I need the opposite on the backwards button:

on (rollOver) {
    this.shape.play();
}

on (rollOut) {
    this.shape.stop();
}

Without knowing the exact layout of your fla, I’d suggest changing _root.currentFrame and _root.prevFrame to shape.currentFrame and shape.prevFrame. Also change press and release to rollOver and rollOut if that’s what you want.

// place this code on your main timeline
 rewind = false;
onEnterFrame = function () {
    if (_root._currentframe > 1 && rewind) {
        shape.prevFrame();
    } else {
        play();
    }
};
// place this code on your rewind arrow
on (press) {
    _root.rewind = true;
}
on (release) {
    _root.rewind = false;
} 

:confused: