Sound.start( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Sound.start( ) Method Flash 5

begin playing an attached or loaded event sound
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 it is stopped manually. See the position property for code that stops a sound after n milliseconds.

loops

A positive integer indicating how many times to play the sound attached to soundObject. To play the sound once, use 1 (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. Applies to nonstreaming sounds only.

Description

The start( ) method is used to play programmatically defined sounds that were added to soundObject via attachSound( ) or loadSound( ). 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( ) or loadSound( ), and it always plays a loaded sound in favor of an attached sound if both are present in the same Sound object.

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. Normally, multiple calls to soundObject.start( ) play multiple instances of the same sound (rather than restarting the sound), except when the sound is a streaming loaded sound, in which case the sound begins playing at the specified secondOffset. In general, sounds should be stopped via stop( ) before being restarted.

The start( ) method works with loaded streaming sounds in Flash Player 6.0.40.0 and later only. However, the loops parameter is not available for streaming sounds in any version of the Player.

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 defaults to 0) boink.start();     // Play only a portion of boink, starting 0.5 seconds in (loops defaults to 1) boink.start(.5);     // Play boink three times from beginning to end boink.start(0, 3);

See Also

Sound.loadSound( ), Sound.position, Sound.stop( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net