Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A simple game sound manager class
package
{
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.media.SoundChannel;
public class GameSoundClass
{
//set var for my sound channel
private static var gameTrackChannel:SoundChannel;
//set and store track information for the music sound to be used
private static var firstTrack:Sound;
public function GameSoundClass()
{
//When ever I need to call the class use the --->( GameSoundClass.Name_Of_Your_Function(); )<---
}
/*Create our function that will load all game sounds.
* This funtion will be called in our preloader
* GameSoundClass.loadAllSounds();
*/
public static function loadAllSounds():void
{
firstTrack = new Sound();
firstTrack.load( new URLRequest("YOUR_TRACK_NAME.mp3"));
}
/*Create our function that will load our firstTrack
* This funtion will be called whenever it is needed
* GameSoundClass.playFirstTrack();
*/
public static function playFirstTrack():void
{
gameTrackChannel = playFirstTrack.play();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment