Highlighted

URLMonitor doesn't work in release build

Explorer ,
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

101

Likes

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

URLMonitor doesn't work in release build

Explorer ,
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

102

Likes

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
Oct 07, 2014 0

Have something to add?

Join the conversation