Easy SoundManger Class (AS3)

As all the excitement from the holidays dies down, I’ve finally found a bit more time to work. I ended up neglecting the blog there for a few weeks but I’m going to attempt to get posts done at least once a week.

That being said, sorry for leaving ya’ll in the dust. As compensation I offer you my brand new SoundManager class! I’ve always hated dealing with sounds in AS3, they make it kind of hard if you want to do anything interesting with them, because then you have to deal with 3 different classes:

Sound
SoundTransform
SoundChannel

With my new class, I’ve eliminated this pain. SoundManager and its functions require no instantiation, so you can reference it right off the bat.

Usage

private var sound:Sound = new TitleMusic();
private var loops:int = 10;

// add sound to play
SoundManager.addSound(sound, "titleMusic", SoundManager.MUSIC );

// play sound
SoundManager.playSound("titleMusic", loops)

// stop sound
SoundManager.stopSound("titleMusic");

// mute/unmute sounds of type MUSIC
SoundManager.musicMuted = true;

// mute/unmute sounds of type SOUND
SoundManager.soundMuted = true;

// set volume of music and sound*
SoundManager.musicVol = .5;
SoundManager.soundVol = 1;

*Setting the volume will undo muting, so take that into account when you call it.

Download

Most of the time the most up-to-date download will be at GitHub, so I advise you download from there. I will post here whenever a big update is released, but not all the time.

GitHub | Pastebin  | Raw Text

 

Thanks for reading, criticism and suggestions are always welcome! If you’re feeling particularly helpful today, go check the project out on GitHub and fork it!

-</rtlshadow>

About these ads

3 thoughts on “Easy SoundManger Class (AS3)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s