tziuka
tziuka

Reputation: 545

Adobe Air Activate/Deactivate events doesn't work

I can't get work Activate and Deactivate events for my Android Application. When I am running it on Windows it is working.

In constructor of the document class I tried this:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);  
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

and

this.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);
this.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

and

 this.stage.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);
    this.stage.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

this are the functions:

private function onActivate(e:Event) : void {
    new BubbleSnd().play();
}

private function onDeactivate(e:Event) : void {
    new AlertSnd().play();
}

Why I can't hear the sounds on my phone? When I press on home button, I deactivate focus so I should hear the sound...but nothing happends. I have used those Events few months ago on another Android App and then they works fine. Thank you!

Upvotes: 0

Views: 1538

Answers (1)

moot
moot

Reputation: 653

Here's standard activate code that should work:

private var application: NativeApplication; 
application = NativeApplication.nativeApplication; 
application.addEventListener(Event.ACTIVATE, activate); 
private function activate(e: Event): void { 
  //do whatever 
}

Upvotes: 1

Related Questions