Skip to content

Instantly share code, notes, and snippets.

@GabeTHEGeek
Created February 5, 2012 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GabeTHEGeek/1748231 to your computer and use it in GitHub Desktop.
Save GabeTHEGeek/1748231 to your computer and use it in GitHub Desktop.
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