• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

URLMonitor doesn't work in release build

Explorer ,
Oct 07, 2014 Oct 07, 2014

Copy link to clipboard

Copied

Hello,

I'm using URLMonitor to detect the Internet connection for my Adobe Air App. It works perfectly when testing through Flash Builder. But as soon as I test it on a release build, the event doesn't get dispatched!!

Had anyone else experienced this?

-----

[Event(name="networkStatusChanged", type="flash.events.Event")]
public class NetworkMonitor extends EventDispatcher
{
private var urlMonitor:URLMonitor;
private var url:String;
private var _connected:Boolean;
public function NetworkMonitor(url:String = 'http://www.google.com')
{
super();
this.url = url;
NativeApplication.nativeApplication.addEventListener(Event.NETWORK_CHANGE, onNetwork_ChangeHandler);
}
protected function onNetwork_ChangeHandler(event:Event):void
{
start();
}      
public function start():void
{
urlMonitor = new URLMonitor(new URLRequest(url));
urlMonitor.addEventListener(StatusEvent.STATUS, onNetStatus_ChangeHandler);
if(!urlMonitor.running)
urlMonitor.start();
}
public function stop():void
{
if(urlMonitor.running)
urlMonitor.stop();
}
public function isConnected():Boolean
{
return _connected;
}
private function onNetStatus_ChangeHandler(event:StatusEvent):void
{
trace("event code " + event.code);
trace("event level " + event.level);
_connected = urlMonitor.available
dispatchEvent(new NetStatusEvent(NetStatusEvent.NETWORK_STATUS_CHANGED,urlMonitor.available));
//stop();
}
}
TOPICS
Development

Views

142

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines