Created
February 5, 2012 22:34
-
-
Save GabeTHEGeek/1748231 to your computer and use it in GitHub Desktop.
A simple game sound manager class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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