I am currently working on a game which has music that speeds up as the game goes on. I want the player to be able to resume when they die, along with starting the music where it left off.
After poking around the forums, documentation, and IRC I didn't find any good answers, so I made a small tweak to the Sfx class, which might be useful (and perhaps worthy of a commit in the next version?). I didn't want to create my own branch just to change a couple lines of code.
Anyways, I changed line 43 to this (added the "pos" parameter):
Code:
public function play(vol:Number = 1, pan:Number = 0, pos:Number = 0):void
then changed line 52 to this (passing in the pos param):
Code:
_channel = _sound.play(pos, 0, _transform);
And likewise for the loop method.
line 67:
Code:
public function loop(vol:Number = 1, pan:Number = 0, pos:Number = 0):void
line 69:
Code:
play(vol, pan, pos);
Now, I can resume music from the last Sfx.position, by passing it into the play() or loop() methods. Alternatively, it may be useful to add an Sfx.position setter method, which basically calls a stop(), and then a play(), passing in the position to play from.