-1

I've made 3 layers.

1 layer as follows: I've created fastForward & fastPrevious buttons using

**

> function whatever()
{
 frame=currentFrame+90;
this.gotoAndPlay(frame);

}
**

I wrote down this code in the beginning of this layer 1.

Layer 2 as follows:

stop();

I wrote down this code somewhere in middle frame.

Layer 3 as follows: Only butttons for layer 3.

This code makes animation jump/next frame by 90 frames, but it also skips the code written(in layer 2) in between these jumps/next. If I write some code on frame 120 or elsewhere then it skips that code and jump to next designated frame while clicking btnfastForward. Simply want to make some bug free fastForward & previous button.

1 Answers1

0

Pretty simple. You just need to go through all the frames in between.

function fastForward(targetFrame:int, mustPlay:Boolean = true):void
{
    // Go to designated frame without skipping any.
    while (currenFrame < targetFrame)
    {
        nextFrame();
    }

    // The "nextFrame" method also performs "stop".
    // Resume playback if needed.
    if (mustPlay)
    {
        play();
    }
    else
    {
        stop();
    }
}
Organis
  • 7,243
  • 2
  • 12
  • 14
  • This is not working. It plays from current frame only when I try to fastForward. It will be great if you give me precise answer. Since I'm naive in AS3 – Deals Programming Mar 13 '19 at 10:24
  • @DealsProgramming So, call **fastForward** when you need it. I don't understand what kind of problem could you possible have with this simple code. – Organis Mar 13 '19 at 11:25
  • I'm calling this function on 'nxtButton' click but it gives error like: Argument Error- #1063 Argument count missmatch. – Deals Programming Jun 13 '19 at 08:58
  • @DealsProgramming That means you are passing wrong number of arguments. My function takes 1 mandatory (target frame number, typed **int**) and 1 optional (typed **Boolean**) arguments. So you can call it like **fastForward(10);** or **fastForward(99, false);**. If you pass less arguments or more, then you get the mentioned error. – Organis Jun 13 '19 at 09:08
  • It's not working though. The code I written as follows: var targetFrame; nxtBtn.addEventListener(MouseEvent.CLICK,fastForward); function fastForward(targetFrame:int mustPlay:Boolean=true):void – Deals Programming Jun 21 '19 at 10:20