[back to index]

Library Reference (v 0.9.0)

Music

For all your music and sound needs.

Like OpenFL, Haxegon uses .OGG files on all platforms except for flash. (This may change in future, and if it does, I'll update Haxegon to match.)
Music.loadsound(soundname:String, volumelevel:Float = 1.0)
Loads in a sound from data/sounds/ - either MP3 or OGG/WAV, depending on platform. 'Sounds' are usually short sounds effects that are played without looping. Optionally set a volume level for the sound (0.5 loads it in at half volume, for example.)
Music.playsound(soundname:String, volume:Float = 1.0, offset:Float = 0.0)
Plays a sound effect. Optionally set a volume between 0.0-1.0, or an optional startpoint (where 1.0 is 1 second into the sound).
Music.stopsound()
Stop any sound effect that's currently playing.
Music.loadsong(songname:String, volumelevel:Float = 1.0)
Loads in a song from data/sounds/ - either MP3 or OGG/WAV, depending on platform. 'Songs' are usually long music files that are played with looping. Optionally set a volume level for the song (0.5 loads it in at half volume, for example.)
Music.playsong(songname:String, ?time:Float = 0.0, ?loop:Bool = true)
Plays a song. Optionally set a startpoint (where 1.0 is 1 seconds into the song), and whether or not to loop.
Music.stopsong()
Stops the currently playing song.
Music.fadeout()
Fades out the currently playing song.