SoundClip

Kind of class:class
Inherits from:Dispatcher
Classpath:org.asapframework.management.sound.SoundClip
File last modified:Thursday, 09 November 2006, 10:57:18
The SoundClip class is used for controlling individual sounds through the SoundManager class.
For most common operations, such as starting, stopping and setting volume, it is recommended to use the SoundManager functions instead of the SoundClip.
Events broadcasted to listeners:
  • SoundClipEvent with type: ON_LOADED
    • Event sent when an external sound has been loaded successfully
  • SoundClipEvent.ON_ERROR

Summary


Constructor
  • SoundClip (inName:String, inMovieName:String, inSound:EventSound, inMovieClip:MovieClip, inVolume:Number)
    • Constructor
Instance properties
Instance methods
  • loadExternalSound (inUrl:String) : Void
    • Load an external sound from a url.
  • setStreaming (inURL:String) : Void
    • Set the sound to stream when playing, and the url to play a stream from.
  • startSound (playCount:Number) : Void
    • Start playing the sound.
  • stop : Void
    • Stop the sound
  • mute : Void
    • Set the volume of the sound to 0.
  • unmute : Void
    • Restore the original volume of the sound.
  • toString : String
Event handlers

Constructor

SoundClip

function SoundClip (
inName:String, inMovieName:String, inSound:EventSound, inMovieClip:MovieClip, inVolume:Number)

Constructor
Parameters:
inName :
unique identifying name
inMovieName:
name of the container movie that contains the movieclip for this sound
inSound :
the EventSound object that contains or will contain the actual sound
inMovieClip:
the movieclip that owns the sound
inVolume :
the initial volume of the sound

Instance properties

isExternal

isExternal:Boolean
(read)

True if the sound is external

isLoaded

isLoaded:Boolean
(read)

True if an external sound has loaded

isLooping

isLooping:Boolean
(read)

true if the sound loops

isPlaying

isPlaying:Boolean
(read)

true if the sound is playing

mIsExternal

private mIsExternal:Boolean = false
(read)

mIsLoaded

private mIsLoaded:Boolean
(read)

mIsLooping

private mIsLooping:Boolean = false
(read)

mIsPlaying

private mIsPlaying:Boolean = false
(read)

mIsStreaming

private mIsStreaming:Boolean = false
(read)

mMc

private mMc:MovieClip
(read)

mMovieName

private mMovieName:String
(read)

mName

private mName:String
(read)

movieclip

movieclip:MovieClip
(read)

The movieclip that owns the sound

movieName

movieName:String
(read)

The name of the container movie

mSound

private mSound:EventSound
(read)

mURL

private mURL:String
(read)

mVolume

private mVolume:Number
(read)

name

name:String
(read)

The identifying name

sound

sound:EventSound
(read,write)

The EventSound object that contains the actual sound

url

url:String
(read)

The url of the external sound

volume

volume:Number
(read,write)

The volume of the sound, 0 - 100

Instance methods

loadExternalSound

function loadExternalSound (
inUrl:String) : Void

Load an external sound from a url. An event (either SoundClipEvent.ON_LOADED or SoundClipEvent.ON_ERROR) is fired after loading. On local systems, this event can come during this call.
The sound is loaded entirely before it can be played.
Parameters:
inUrl:
the url for the sound to be loaded.

mute

function mute (
) : Void

Set the volume of the sound to 0. The original volume is preserved, and can be restored with unmute.().

setStreaming

function setStreaming (
inURL:String) : Void

Set the sound to stream when playing, and the url to play a stream from. This does not start playing - use startSound for that purpose.
Parameters:
inURL:
the url of the sound to be streamed

startSound

function startSound (
playCount:Number) : Void

Start playing the sound. If it is playing, stop it first.
Parameters:
playCount:
the number of times to play the sound. If 0 or less, the sound loops infinitely

stop

function stop (
) : Void

Stop the sound

toString

function toString (
) : String

unmute

function unmute (
) : Void

Restore the original volume of the sound.

Event handlers

onEventSoundComplete

private function onEventSoundComplete (
) : Void

Event handler for the onSoundComplete event from the EventSound object. Is called when a sound is done playing.
If a sound loops, it gets played a large number of times in a loop by the Flash player. When done with the large number, this event is fired.
Restarting the sound after receiving this event results in a small glitch in the sound.

onEventSoundLoaded

private function onEventSoundLoaded (
e:EventSoundEvent) : Void

Event handler for the onLoad event from the EventSound object. Is called when an external sound has been loaded, or an error has occurred.
Events broadcasted to listeners:
  • SoundClipEvent with type: ON_LOADED
    • Event sent when an external sound has been loaded successfully
  • SoundClipEvent.ON_ERROR