Reputation: 12054
I have developped a small application in Flex Mobile (Project actionscript mobile in flex4.7). I have a background music.
My problem is that music is still being played when application is minimzed (Home android button): I would like the music to be paused when Home button is being pressed and resumed, when application is active again.
Any clues ?
Upvotes: 1
Views: 1036
Reputation: 1339
In your document class, listen for the Stage class's ACTIVATE and DEACTIVATE events:
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
public function Main():void
{
stage.addEventListener(Event.ACTIVATE, onAppActivated);
stage.addEventListener(Event.DEACTIVATE, onAppDeactivated);
}
private function onAppActivated(e:Event):void
{
// Play audio
}
private function onAppDeactivated(e:Event):void
{
// Pause audio
}
}
}
Upvotes: 4