PDA

View Full Version : Sound problem



fw2803
December 4th, 2007, 09:04 AM
Hi all
I have been working with the sound of my game.

I currently have 3 sound clips, all exported. I put the following codes to the player's tank.


onClipEvent (load) {
var tankDie = new Sound()
tankDie.attachSound("tankDie")
var tankMiss = new Sound()
tankMiss.attachSound("tankMiss")
var tankGatt = new Sound()
tankGatt.attachSound("tankGatt")
}


Then I play the sounds at various points


onClipEvent (enterFrame) {
//when health is less than or equals 0, play tankDie (tankDie.start())
//when the tank fires missiles, play tankMiss (tankMiss.start())
//when the tank fires gattling cannon, play tankGatt (tankGatt.start())
}


I got only 2 of them working. tankDie.start() and tankGatt.start() worked. But tankMiss.start() did not play the sound. I have checked the linkage and I cannon find any problems. I also tried some other sound clips but I still could not solve the problem.

The most ridiculous thing is that for firing missiles and gattling cannons, the codes are nearly the same. However, only the gattling cannon sound clip worked but not the missile sound clip...

Can anyone help?

Charleh
December 4th, 2007, 10:03 AM
I just create a function which you just pass a string to - it will create a new sound object and attach the sound and play it... works fine for what I want :)



function PlaySound(soundName:String) {
var s:Sound = new Sound();
s.attachSound(soundName);
s.play(<er cant remember the order of sound params>);
}

Then just call it

PlaySound("tankDie");

fw2803
December 4th, 2007, 10:19 AM
Does the bit rate and sampling rate matter? Those that I could use AS to play have 11kHz, mono, 16bit.

But I also find that some with the same properties cannot be played... What's happening... The problem now is that I can't even play the sound clip, leave alone efficiency...