First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Kenny Bellew | Website: http://www.cowfly.com

How to Fast Forward and Reverse Sound Objects

Fig. 13: Example of fast forwarding and reversing a sound object

When I first wrote this tutorial a couple of years ago, it was impossible to apply the following to streaming sound objects that use the loadSound method because it was only possible to start streaming sounds from their beginning. However, the current flash player seems to pause and restart streaming sounds just fine. Obviously, if you fast forward further than a streaming sound has loaded, you will have problems. This is not an issue with event sounds. Frankly, it seems unwise to make it a regular practice of using either the position or duration properties of a streaming sound (especially the duration, as it will not be accurately revealed until the sound fully loads). Fast forwarding, reversing and pausing a sound object using the attachSound method works wonderfully.

The following approach will show how to have the sound skip forward and backward while the fast-forward or rewind button is being held down. In this example, sound will be heard skipping forward or backward, but it will not be legible and it will not sound like audio time is compressed. Experiment with the Flash example in Fig. 13 to understand how it will sound.

When the fast forward button is held down, the sound object will stop, skip forward in position slightly, play very briefly, stop and repeat this cycle until the button is released. The speed of fast-forward or reverse can be controlled by how much is added to or subtracted from the sound object position each time. For this example, the increment is fairly small because the sound is so short. For practical use, a setting of a few seconds should work nicely.

  1. Define your sound object.
  2. Place buttons on the _root timeline. For this example, the reverse button will have the instance name of "REVButton", and the fast-forward button will be called "FFButton".
  3. Place the following code on a one-frame movie clip that loops:

this.onEnterFrame = function () {
if (REV==1 && myMusicPosition>0) {
//The .5 is the decremented amount.

revButton.onPress = function () {
revButton.onRelease = function () {
//Fast Forward
if (FF==1 && myMusic.position < myMusic.duration) {
//The .5 is the incremented amount.

FFButton.onPress = function () {
FFButton.onRelease = function () {

FF, REV and Pausing a Streaming Sound Object

Here is the same player, but this time the sound is set to streaming. This will
show you the performance difference between the two. The file will begin loading
when the play button is pressed. The file is already compressed to 40 kbs, and
will lose further data as it streams (in other words, the original sounds better).
Special thanks to the band, gunderson,
for allowing the use of their music. This song is called Fade.

Fig.13b: Example of FF, REV and Pausing a streaming sound object.

» Level Intermediate

Added: 2004-10-12
Rating: 8 Votes: 31
» Author
Kenny Bellew is a technical writer and freelance flash programmer who specializes in Flash audio. He lives in Minneapolis, MN.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» 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
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» 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.