A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11249 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Matthias Kannengiesser
» Title: FS 3D Rotation Menu
» Description: This nice 3D Menü could be easy setup and we are quite sure you will like it - a preloader is included.
» More by Matthias Kannengiesser


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6393 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: The Chopping Block
» Comments: The Chopping Block, Inc. is a full-service graphic design studio founded on the principle that good design spans all mediums.


Random Links | Add your own Flash Related Links
Flash Tutorials 1200 Tutorials 7 New Tutorials Added!
What's New | Top100

» After Effects Quality Effect using AS3
» FLV to 3GP: Convert video files from FLV (Flash Video) to 3GP for Mac
» create Christmas business flash presentation with hyperlinks
» Let Photos Show Your Happy Family this Christmas and Upload YouTube
» PowerPoint show to DVD slide show--- PPS to DVD
» How to burn FLV to DVD for Mac
» How to Create Christmas Flash Greeting Ecard with photos and music
» Getting Started In Flash
» How to convert FLV video to MP3 audio for Mac OS
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Product Designer
Aquent
US-WA-Redmond

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories Movie Play Forward or Backward-Simulate Video Player
Author: Vivian | Website: http://www.sothink.com/product/swfquicker/index.htm |

 
Page 1
1

Movie Play Forward or Backward-Simulate Video Player

Want to make a video player with 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
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.

2 Create buttons such as stop, back, pause, play, etc. Details are not shown here.
[endif]

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.>[endif]

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.
}



The codes of Pause button are as follows:

Code:

on (release)
{
_root.video.stop();
_root.playing = false;
displayInfo("Pause");
}



The codes of Play button are as follows:

Code:

on (release)
{
_root.video.play();
_root.playing = true;
displayInfo("Play");
}



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:

Code:

on (press)
{
_root.back = true;
displayInfo("Back");
}
on (release)
{
_root.back = false;
if (_root.playing)
{
_root.video.play();
displayInfo("Play");
}
else
{
_root.video.stop();
displayInfo("Pause");
} // end if
}



The codes of Play Backward button are as follows:

Code:

on (press)
{
_root.forward = true;
displayInfo("Forward");
}
on (release)
{
_root.forward = false;
if (_root.playing && _root.video._currentframe <_root.video._totalframes)
{
_root.video.play();
displayInfo("Play");
}
else
{
_root.playing = false;
_root.video.stop();
displayInfo("Pause");
} // end if
}



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:

Code:

on (release)
{
_root.video.prevFrame();
_root.playing = false;
displayInfo("Step back");
}



The codes for Back a Frame button are as follows:

Code:

on (release)
{
_root.video.nextFrame();
_root.playing = false;
displayInfo("Step forward");
}

[b]8[/b] The scaling includes 50%, 100% and 135% of Zoom button can be customized as your desire.

on (release)
{
switch (_root.video._xscale)
{
case 135:
{
_root.video._yscale = _root.video._xscale = 50;
displayInfo("50%");
break;
}
case 50:
{
_root.video._yscale = _root.video._xscale = 100;
displayInfo("100%");
break;
}
default:
{
_root.video._yscale = _root.video._xscale = 135;
displayInfo("135%");
break;
}
} //end of switch
//back to original play state by checking the value of _root.playing, Please don’t
//use play() when the current frame is the last frame. or
//the video will play from the beginning.
if (_root.playing)
{
if (_root.video._currentframe <_root.video._totalframes)
{
_root.video.play();
} // end if
}
else
{
_root.video.stop();
} // end if
}


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.

1

» Level Intermediate

Added: : 2005-12-28
Rating: 8.25 Votes: 8
Hits: 1157
» Author
Want to get a new level of expressiveness and efficiency to create presentations, interactive experiences and websites? Want to engage, enlighten and empower yourself so that you can get more out of now? SWF Quicker is the right kit to get them all. Creative you can definitely design professional Flash movies rich with all things you need. So, no more guessing! Try Versatile Flash Maker now!
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers