PDA

View Full Version : Stop sound from playing continuosly on keyisdown


juliecat
05-07-2007, 06:59 AM
Hi people, got a problem any insights, tutorials online or clues gratefully received.

I'm using a KeyIsDown action to trigger a sound. This works fine, however if the key is pressed down continuously it starts the sound playing again and again. What I need is somekind of control that detects the keydown, triggers the sound but then doesn't keep re-starting the the sound whilst the key is depressed. Is there an action in the sound commands that detects to see if a sound is playing which I can use - like the old "soundIsBusy" command in lingo?

many thanks


julie
*

Dazzer
05-07-2007, 07:51 AM
AS2 or AS3?

AS3 does not have Key.isDown().

Anyway, the easiest way is to have a flag that says "sound is playing" then change it accordingly etc

dthought
05-08-2007, 08:39 PM
I just had a search through for some sort of an isPlaying type variable, however none exists. A little frustrating, but not entirely unworkable.

Rather than setting other variables, you could perhaps have it such that when the sound is not playing, its volume is 0. When the sound is playing, its volume transform is 1.0 (AS2 and below used arbitrary values between 0 and 100). Therefore you could check - if the volume is 0, start playing. If the volume is 1.0, do not start again, and on key up, set the volume to 0 and stop playing.

Dazzer
05-08-2007, 09:09 PM
there isn't.
Because the Sound object doesn't control playback.
You work with the SoundChannel object. But there's no way to figure out if there's a Channel associated with a Sound.

There is an event from the SoundChannel class called SoundComplete though.