是否可以检查互联网连接,而不是根据连接/无连接选择查看?
谢谢
也许下面的代码会有用:
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.TestConnectionHomeView" applicationDPI="160" creationComplete="init()">
<fx:Script>
<![CDATA[
import air.net.URLMonitor;
private var monitor:URLMonitor;
public function init():void{
monitor = new URLMonitor(new URLRequest('http://www.adobe.com'));
monitor.addEventListener(StatusEvent.STATUS, announceStatus);
monitor.start();
}
public function announceStatus(e:StatusEvent):void {
trace("Status change. Current status: " + monitor.available);
}
]]>
</fx:Script>
</s:ViewNavigatorApplication>
请参阅此链接检测 HTTP 连接以获取更多说明。