Something I whipped up for myself in a few minutes.
This cuts down the code I need to play a sound by about 2 lines haha, but I think its pretty useful, check it out especially if sounds in Actionscript 3 aren't making sense for you. =)
FX.as -
package
{
import flash.display.MovieClip;
import flash.media.Sound;
import flash.media.SoundChannel;
public class FX extends MovieClip
{
var sound:Sound;
public function FX (type:Object)
{
sound = new type();
var fx:SoundChannel;
fx = sound.play();
}
}
}
Used like so:
var shot:FX = new FX(gunshot1);
gunshot1 is the class of the sound i want to use, right click your sound in the library (like gunshot.wav), and click linkage. Make its class be something like gunshot1, or mysfx or whatever.
Dec 21, 2008
Subscribe to:
Post Comments (Atom)
2 comments:
nice work, added some looping and volume control and it is very handy, thanks!
I might borrow this for Ludum Dare if ya don't mind.
Post a Comment