Name

Sound.start( ) Method — begin playing an attached sound

Availability

Flash 5

Synopsis

soundObject.start(secondOffset, loops)

Arguments

secondOffset

A floating-point number indicating the time in seconds at which to start playing the sound attached to soundObject (often called an entry point). For example, a secondOffset of 1 starts playback one second after the sound’s actual beginning as defined in the Library. The default is 0. There is no provision for an exit point (the time at which to stop playing the sound). The sound plays until its end unless stopped manually.

loops

A positive integer indicating how many times to play the sound attached to soundObject. To play the sound once, use 1 (which is the default); to play the sound twice in succession, use 2, and so on. The portion of the sound from secondOffset is repeated to its end the number of times specified by loops.

Description

The start( ) method is used to play programmatically-defined sounds that were added to soundObject via attachSound( ). The start( ) method does not play all the sounds in a clip or movie; it plays only the sound most recently attached to soundObject via attachSound( ).

To play only a portion of the sound attached to soundObject, use the secondOffset argument. To play the sound attached to soundObject repeatedly, use the loops argument.

Example

// Create a new Sound object
boink = new Sound( );

// Attach a sound exported as boink to the Sound object
boink.attachSound("boink");

// Play all of boink; soundOffset ...

Get ActionScript: The Definitive Guide 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.