Please i am new to Flex and Actionscript 3, but i know its an OOP language, I'm coming from a Java Background. I have a class that helps me check if the user of my AIR app has an internet connection it works well when included directly in my mxml class. Wanted to know if its possible to insert it in an actionscript class and reuse it in any mxml component class i wish to.
EDIT
package components
{
import air.net.URLMonitor;
import flash.events.StatusEvent;
import flash.net.*;
public class NetworkChecker
{
private var monitor:URLMonitor;
private var myURL = new URLRequest("http://www.adobe.com");
public function NetworkChecker()
{
myURL.method = "HEAD";
monitor = new URLMonitor(myURL);
monitor.start();
monitor.addEventListener(StatusEvent.STATUS, on_Connection);
}
public function on_Connection(event:StatusEvent):void
{
if(event.target.available == true)
{
trace("Internet Connection is available");
}
else
{
trace("No internet Connection");
}
}
}
}
Please how do i call this code from an mxml component? it works well when i include it directly in the fx:Script tag. I need to know if event.target.available is true of false in my mxml component...