User Guide
Using device sound (Flash Professional only) 53
Playing external device sounds
In addition to playing device sounds that are bundled in the published SWF file (see “Using
bundled device sound” on page 48), you can also load and play external sound files. To play
external device sounds you use the
loadSound() method of the Sound object. As with
bundled device sound, the Flash Lite player passes the externally loaded audio to the device to
decode and play.
The following information about playing external device sounds in Flash Lite 2.0 is important
to remember:
■ Unlike in the desktop version of Flash Player, externally loaded sounds in Flash Lite 2.0
are always treated as event sounds. This means that external device sounds do not
stream—that is, play as they are being downloaded. The sound data must download fully
before you can play the sound. For the same reason, you must call the Sound object’s
start() method to play the sound once it is fully loaded (see the following code
example).
■ The Flash Lite 2.0 implementation of the loadSound() method does not support that
method’s second parameter (
isStreaming). Flash Lite ignores this parameter if it is
present.
■ Flash Lite 2.0 does not play externally loaded MP3 files natively. If your application loads
an external MP3 file, Flash Lite passes the sound data to the device to decode and play, as
it does with any externally loaded sound file.
The following code shows how to load and play an external sound file:
// Create the sound object.
var mySound:Sound = new Sound();
// Define onLoad handler for sound,
// which starts the sound once it has fully loaded.
mySound.onLoad = function(success){
if(success == true) {
mySound.start();
}
}
// Load the sound.
mySound.loadSound("http://www.macromedia.com/audio.midi");