Liam Thomas
Liam Thomas

Reputation: 71

Sound not being played

var sound:Sound = new Sound(new URLRequest("Phone.wav"))
sound.play(0, 20);

Why does sound not play? There are no errors.

Upvotes: 0

Views: 299

Answers (2)

puggsoy
puggsoy

Reputation: 1280

Flash doesn't support loading external WAV files with the Sound class, only MP3s. I don't know why it isn't giving any errors but I haven't used the Sound class much myself so it might be normal.

There are three solutions for this. First of all, WAVs are supported if you import them into the library as Sound objects. This is probably the best choice if you're using the Flash IDE. If you're not using the IDE, you may be able to embed the file instead using Flex's [Embed] tag, if you're compiling it using the Flex SDK.

Otherwise, can either convert your sound to an MP3 file and load it as usual:

var sound:Sound = new Sound(new URLRequest("Phone.mp3"));
sound.play(0, 20);

Or, if you prefer to use a WAV, you can use the as3wavsound library. Here's a tutorial outlining how to use it.

Hope that helps!

Upvotes: 1

Siva
Siva

Reputation: 359

You need to use a SoundChannel try this.

var soundChann:SoundChannel;
var sound:Sound = new Sound(new URLRequest("Phone.wav"))
soundChann = sound.play(); 

Upvotes: 0

Related Questions