AIR and Network Detection

We can detetct the network in AIR using following code ::

Need to use ‘ServiceMonitorShim’ complied clip from AIR components in your fla file.

import air.net.URLMonitor;
import flash.net.URLRequest;
import flash.events.StatusEvent;
var monitor:URLMonitor;
monitor = new URLMonitor(new URLRequest(‘http://192.168.0.57’));
monitor.addEventListener(StatusEvent.STATUS, announceStatus);
monitor.start();
function announceStatus(e:StatusEvent):void
{
         trace(“Status change. Current status: ” + monitor.available);
}

AIR – Change the size of Stage at runtime dynamically

Yesterday I came across a fact that you can resize the stage size dynamically at runtime using actionscript code. But this is limited to AIR only (either Flash or Flex) but not supported in normal Flash.

Following is the code to change the width and height of the stage at anytime (runtime) using actionscript in AIR (Flash) ::

stage.stageWidth = {numericValue};

stage.stageHeight = {numericValue};

Of course, we can change the width and height of the stage in Flash (normal) using JavaScript or some other external script which controls the container of the swf file.

Naresh Khokhaneshiya