views:

12

answers:

1

I have designed quite a long flash movie, it's for an advert.

The movie was designed in several flash files, each has been combined into a single movie clip and then all the movie clips have been moved into the master document.

Each movie clip is on a single slide.

They play through and when a clip reached the end I have used the actionscript root.gotoAndPlay(x) where x is the slide number of the next clip in the sequence as such my timeline looks like this:

timeline example

I need to add a control feature with four buttons:

  • play
  • pause
  • rewind
  • fast forward

How can I do this? I can only find resources online that allow for control features where everything is on the same timeline, and not for controlling movie clips.

I have little experience of actionscript however am experienced in other languages (JS and PHP).

+1  A: 

First, give an instance name to each of your scene movie clips. Make it something that you can parse, such as "clip_1", "clip_2", "clip_3", etc.

Second, put frame labels on each of the frames where you have scene clips - named similarly to the movie clips: "scene_1", "scene_2", etc.

Now, create a new actionscript layer in your main timeline and make sure that its timeline extends to the end of the main timeline. it will automatically have a blank keyframe in frame 1.

We're going to create a variable to hold a reference to the clip that is currently playing:

var currentClip:MovieClip = null;

There are a number of ways that we can track the current clip - all of them are tedious at some point if you haven't planned the implementation ahead of time. I'm going to try the one that I think will be easiest for you to implement.

In each of your actions frames where a movieclip resides you're going to add the following line of code:

currentClip = eval("clip_x");

You'll need to change the value of x in "clip_x" in each frame to match the number of the clip that's in the frame.

Now, go back to the second actions layer that you created - we're going to handle the rev, ff, play, and pause actions here.

function Play() : Void {
   if(currentClip!=null && currentClip!=undefined) {
        currentClip.play();
   }
}

function Pause() : Void {
   if(currentClip!=null && currentClip!=undefined) {
        currentClip.stop();
   }
}

Ok, so we have play and pause covered. How you handle FF and REV is going to depend on how you want the user to interact with those buttons. Generally there are two approaches: "Jump" and "Scan". The "Jump" approach moves the playhead forward/back a predetermined number of frames each time the button is pressed. The "Scan" approach moves the playhead forward/back X frames per secoond for as long as the button is held down, where X is the fps rate of your movie.

I think that the Jump approach will be the easiest for you to implement:

var JUMP_RATE = 30; //this is the number of frames to "jump" each time we hit the ff or rev buttons

function FF() : Void {
     if(currentClip!=null && currentClip!=undefined) {
           if(currentClip._currentFrame + JUMP_RATE < currentClip._totalFrames)
                 currentClip.gotoAndPlay(currentClip._currentFrame + JUMP_RATE);
           else
                 currentClip.gotoAndStop(currentClip._totalFrames);
     }
}

function REV() : Void {
     if(currentClip!=null && currentClip!=undefined) {
           if(currentClip._currentFrame - JUMP_RATE > 0)
                 currentClip.gotoAndPlay(currentClip._currentFrame - JUMP_RATE);
           else
                 currentClip.gotoAndPlay(0);
     }
} 

Now all that's left for you to do is create your buttons and add the function calls to their onPress or onRelease events.

Good luck!

Brian Driscoll
Wow! Thanks for that - better late than never
Ashley Ward