Skip navigation
Currently Being Moderated

How do you create a fast forward and rewind button?

May 29, 2012 10:15 PM

Tags: #fast_forward #rewind

I would like to create a simple fast forward and rewind button. I am getting sporadic results with the rewind button. I would like the playhead to skip 3 seconds (72 frames) at a time when the user hits the fast forward or rewind button. They should be able to hit either buttons repeatedly. If  playhead is  under 3 seconds then it will go to the first frame.

 

Here's the code:

 

var FrameNumRewind:Number = this.currentFrame;

FrameNumRewind = 0

 

stage.addEventListener(MouseEvent.MOUSE_DOWN, page_watch);

function page_watch(event:MouseEvent):void

{

if (event.target == bnt_Fast)

    {

    var FrameNumFast:Number = this.currentFrame;

    this.gotoAndPlay(FrameNumFast +=72);

    }

 

    if (event.target == bnt_Rewind)

    {

       //Will take the frame head to the first frame if less than 73 frames.

       if(FrameNumRewind <=73)

        {

        SoundMixer.stopAll();

        this.gotoAndPlay("1");}

        }

       

        else

        {

        this.gotoAndPlay(FrameNumRewind-=72);

        }

 

    }

 

What am I doing wrong? Is there a better way to do this?

I would appreaciate any help or any references.

 
Replies
  • Currently Being Moderated
    May 30, 2012 4:28 AM   in reply to QuigleyMcCormick

    You do not need to be using the two "Frame..." variables.  You can use the currentFrame property instead.  When you use specify  this.gotoAndPlay("1");  you do not use quotation marks because the argument is a numeric value, not a string.  You should assign the listeners to the buttons instead of the stage.  Let each have its own event handler function.  When you press down on the button assign an ENTER_FRAME listener to call a function for changing the frames, and when you release it, remove that ENTER_FRAME listener.

     
    |
    Mark as:
  • Currently Being Moderated
    May 30, 2012 10:25 AM   in reply to QuigleyMcCormick

    One thing you should take care of is that you should not nest named functions within other functions.  Pull that ff72 function out by itself.

     

    The currentFrame property is a read-only property, but you are trying to change its value using code in this line...

     

        this.gotoAndPlay(this.currentFrame +=72);

     

    So change that line to be

     

       gotoAndPlay(currentFrame+72);

     

    noticing that I took the "this." references out as well.  They are more often unnecessary in AS3 scenarios.

     
    |
    Mark as:
  • Currently Being Moderated
    May 30, 2012 12:36 PM   in reply to QuigleyMcCormick

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points