17.8. Looping Sounds

Problem

You want to loop the playback of a sound.

Solution

Set a Loop value for the sound in the Property inspector.

Discussion

Flash allows you to loop sounds within your movies. This can be a great benefit to you, because you can create longer soundtracks without increasing your movie’s file size. You can import a short sound file, add it to a keyframe as in Recipe 17.3, and then set the number of times you want it to loop. You can loop a sound only in whole number increments. For example, you can loop a sound three times, but not three-and-a-half times. And if you attempt to enter a non-integer value, Flash will prompt you to fix your entry.

In order to set the number of times to loop a sound, select the keyframe into which you have placed the sound, and then locate the Loop field in the Property inspector. By default, the loop value is 0. A value of 1 or less (including negative numbers) results in the sound playing once. Otherwise, the sound plays the number of times you specify, without any pause in between. The valid range of values for the loop value extends up to 2,147,483,647. If you enter a value greater than that, Flash will automatically reassign a value of 2,147,483,647.

Generally, looping works best with sounds that you have synchronized using either the Start or Event setting. Because of the way that the Stream synchronization works, Flash requires that you first create enough frames in order to play the sound. In most looping scenarios, this is not ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.