View comments | RSS feed

Sound.loadSound()

Availability

Flash Player 6.

Usage

my_sound.loadSound(url:String, isStreaming:Boolean) : Void

Parameters

url The location on a server of an MP3 sound file.

isStreaming A Boolean value that indicates whether the sound is a streaming sound (true) or an event sound (false).

Returns

Nothing.

Description

Method; loads an MP3 file into a Sound object. You can use the isStreaming parameter to indicate whether the sound is an event or a streaming sound.

Event sounds are completely loaded before they play. They are managed by the ActionScript Sound class and respond to all methods and properties of this class.

Streaming sounds play while they are downloading. Playback begins when sufficient data has been received to start the decompressor. For more information, see "Working with Sound" in Using Flash.

All MP3s (event or streaming) loaded with this method are saved in the browser's file cache on the user's system.

Example

The following example loads an event sound, which cannot play until it is fully loaded:

var my_sound:Sound = new Sound();
my_sound.loadSound("song1.mp3", false);

The following example loads a streaming sound:

var my_sound:Sound = new Sound();
my_sound.loadSound("song1.mp3", true);

See also

Sound.onLoad

Comments


recoveredfromflashMX2004 said on Aug 4, 2004 at 4:21 PM :
senocular said on Apr 24, 2004 at 3:19 PM :

"Event sounds are completely loaded before they play. They are managed by the ActionScript Sound class and respond to all methods and properties of this class."

is not necessarily true as sounds loaded with an isStreaming value of false will not work with getBytesLoaded.


Fumio Nonaka said on Apr 29, 2004 at 2:36 AM :

The second parameter, isStreaming, is optional. Its default value is
false, which specifies an event sound.
LiangShu said on Oct 21, 2004 at 4:30 AM :
I got some problems when user installed XP SP2 on their pc. I made flash speaker to load one mp3 from subdomain. I created crossdomian.xml and it works fine for me [2003 server] but it is doesnt works for someone who has installed XP and SP2. any ideas?
bahj said on Dec 7, 2004 at 2:48 PM :
I am using loadsound to load a mp3 for example:

var mysound1:Sound = new Sound();
_global.mysound1;
mysound1.loadSound("mp3/welcomeMsg.mp3", true);
mysound1.stop();

When I test the Flash Projector. EXE file. I here the sound for a brief second. Is there a way to stop the sound object from plaing even though I told it to stop already.
Alexander Palmo said on Dec 28, 2004 at 12:50 PM :
I'm using loadSound() in a "slideshow with audio" project for a large
pharmaceutical company. Everything works perfectly for 90% of the
users. Of course, the 10% that it doesn't work for are the client's
computers...

I've already ruled out .mp3 blocking at the proxy level.

Basically, it will load and play the first few slides (anywhere from 3 to 6)
and then it will just hang. Calling the loadSound() function again has no
effect from here on out. Once it breaks, you have to refresh the page with
the flash movie to get it to work again.

Also, there doesn't appear to be a way to capture any error messages
from the server (i.e. a Proxy Timeout.) The "onLoad" function never gets
triggered (either true or false.)

Does anyone have any tricks for how to detect error and/or re-start
sound after it breaks? (Keep in mind I'm publishing to Flash 6/MX.) Some
help would be greatly appreciated...
glenn_a_m said on Mar 13, 2005 at 9:15 PM :
MAC USERS BEWARE!!!

once you have started an mp3 stream, you can stop it playing, BUT
you can't stop it from loading,

this is VERY irritating.

If you want to play a different track, you just keep using more and
more bandwidth, until all net access falls in a heap.

This issue ahs been around for three years and still no fix!
No screen name said on Jul 24, 2005 at 6:36 AM :
Some mp3's I load using loadSound, are played too fast ( like 3x faster or something). I have tried to load sounds streaming or as Event, but that did not make any differences. I have also tried to set the framerate of my fla to 1 fps (!) but nothing changed. Does anybody experience the same problems, or does anybody know what I am doing wrong ?
No screen name said on Jul 28, 2005 at 5:47 AM :
When I use this function, it begins loading the sound. However, during this loading time no other loadClip functions will start downloading from the interent until the song has finished download, then they continue. Is there a way around this?
Joe.DaCoda said on Aug 30, 2005 at 6:42 PM :
I found my mp3 files playing too fast was due to the sample rate I recorded the sound files in. Flash requires the sample rate to be set to one of the following: 11KHz, 22KHz, or 44.1KHz. I changed my sample rate of all my mp3's to 44.1KHz, and they played fine.
jpsarracco said on Sep 2, 2005 at 3:02 PM :
I was able to kill a sound that was loading by using the loadSound() method with an empty url property on the loading sound object reference. So if mySnd was loading, I used mySnd.loadSound("") with an empty string and it stopped loading the sound.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001680.html