First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Kenny Bellew

How to Start, Stop and Loop a Sound Object

The syntax for starting a sound object is as follows:

Fig. 03: Example of starting and stopping

It is commonly used as follows:

In this example, "firstSound" is the instance name of the sound object. The "secondOffset" refers to the amount of time, in seconds, that you would like to skip before starting to play the sound (this will be described in more detail later). The "loop" refers to the number of times you want the sound to loop. In the above example, this would start firstSound at its beginning position of zero and loop it 999 times.

The syntax for stopping a sound object is as follows:


It is commonly used as in the following example:


Alternately, the ActionScript could also appear as:


In the first above example of stopping a sound object, the linkage identifier "firstSound01" is used. If the linkage identifier is not used, all sounds will stop - unless the sound object is defined as being associated with a specific movie clip (How to associate the sound object to a movie clip is described in the next section). For example, if you want to stop one of three sounds that are currently playing, and the sound was not assigned to a specific movie clip when it was defined, then you must specify the linkage identifier name as part of the stop command.

If you associate the starting of a sound with an event like a button press, it's a good idea to keep the sound from playing if it is already playing (unless you want multiple copies of the sound object playing at the same time). For example:

on (press) {
if (playing!=true) {

And when the sound is stopped by a button:

on (press) {
playing=false; }

In the Flash example Fig04 below, notice how the sound object was defined (as described above the start buttons) and the result of pressing the various buttons (as described below the stop buttons). Press both green play buttons to have both sounds running at the same time. Experiment with the various combinations.

Fig. 04: Example of various effects of different ways of defining and stopping a sound object
» Level Intermediate

Added: 2002-08-13
Rating: 8.98 Votes: 664
(10 being the highest)
» Author
Kenny Bellew is a technical writer in Minneapolis, MN. He's currently interested in becoming involved in other writing-related Flash projects.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.