Movie Play Forward or Backward-Simulate Video Player

Want to make a video player with control buttons, process control block totally by yourself? Want to add a favorite Flash to your video player? SWF Quicker can do share all these experience with you. Welcome to our tutorial house!

Series: SWF Quicker 2.0
Prepared work: download Sothink SWF Quicker -- http://www.sothink.com/product/swfquicker/download.htm
Can you imagine how to make it?
1. Launch SWF Quicker and Look at the Properties panel. Set movie's width as 500, height as 470.
Create a new movie clip and import a SWF file as our video to this movie clip. In this example, we choose a commonweal AD as the imported SWF.

It is better to notice that Actionscript can not control the sub-movie clip, which continues to play when you press button to stop the main movie clip. So you should break apart the sub-movie clip first.

Drag the movie clip to the stage from library and enter "video" as its instance name.

3. Create another movie clip to show play state. I show you timeline as following. Position a blank dynamic text block, set the properties as Font: Arial; Font size: 16; Font color: red; Var: info. The information shown in the text block lasts for 24 frames while you press one of the buttons. The actionscript of frame 25 in Action Layer is: stop()-means to stop movie clip.

Drag the movie clip, which is to show play state to stage and enter "infoMC" as its instance name.

4. Add actionscript to frame 1 to initialize process. In addition, set the corresponding function for later use.

Code:

//use displayed information by this function.
function displayInfo(txt)
{
//set prompt information in infoMc
_root.infoMC.info = txt;
//play infoMC
_root.infoMC.gotoAndPlay(1);
} // end of the function
//============================
displayInfo("Play");
_root.playing = true; //variable indicate video play state. Variable indicate video play state.
stop();
//============================
function onEnterFrame() {
if (_root.forward) {//check this value to make sure whether to execute play forward of video of not.
var targetFrame = _root.video._currentframe+4;
//Stop at the end of video, or the video will play from the beginning.
if (targetFrame>=_root.video._totalframes) {
targetFrame = _root.video._totalframes;
}
_root.video.gotoAndStop(targetFrame);
}
if (_root.back) {//check this value to make sure whether to execute back of video of not.
var targetFrame = _root.video._currentframe-5;
//stop at the beginning when the video begins to play.
if (targetFrame<=0) {
targetFrame = 0;
}
_root.video.gotoAndStop(targetFrame);
}
};

5. Add actionscript to each button. Stop, Pause, Play three buttons are simpler comparing to others. Please notice you should set the value of _root.playing for video play state.
The codes of Stop button are as follows:

Code:

on (release)
{
_root.video.gotoAndStop(1);//Back to frame 1 and stop. _root.playing = false;//set the video play state as stop.
displayInfo("Stop");//use the former created function, which is to display information.
}

6. The value of Play Forward button and Play Backward button is TRUE when it is pressed to set _root.forward or _root.back. The event onEnterFrame executes the corresponding program to video when it checks out the value changes. The video backs to the original play state when mouse is released according to _root.playing.
The codes of Play Forward button are as follows:

7. Buttons "Skip a Frame" and "Back a Frame" are easier comparing with the above two. You can make them by prevFrame() and nextFrame() of movie clip. Please remember to set the value of _root.playing because the video is still pause after you use the two functions.
The codes for Skip a Frame button are as follows:

9. Ok, work is almost done. The rest is depending on your beautification. For that the video may display expending the limited area, you need to add a mask area. It is better if a background is added to furnish the group of buttons.
The process control block, which is designed to simulate the play process, is easier comparatively. The rule is to specify the process position by the properties of _currentframe and _totalframes in video.

Glad to share learning experience with you! Hopefully it is useful to many of you. Any time, Good luck!

If you are interested in Sothink SWF Quicker -- a Flash Maker with a lot of features, such as create Flash Video, support ActionScript 2.0, include plenty of built-in templates & animated effects, etc., You can have a tour of this Flash software here.

» Description:
I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all

» Description:
Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.