Adobe Air - 检查互联网连接 [英] Adobe Air - Check for internet connection
问题描述
我正在使用 Adobe Flash CS 5 构建 Air 应用程序.我需要检查互联网连接是否可用.
I'm building an Air app with Adobe Flash CS 5. I need to check if an internet connection is available.
我遇到了这个错误:
1172:找不到定义 air.net.1046:未找到类型或不是编译时常量:URLMonitor.
1172: Definition air.net could not be found. 1046: Type was not found or was not a compile-time constant: URLMonitor.
这是我的代码:
import air.net.*;
var monitor:URLMonitor;
function checkInternetConnection(e:Event = null):void
{
var url:URLRequest = new URLRequest("http://www.google.com");
url.method = "HEAD";
monitor = new URLMonitor(url);
monitor.pollInterval = 3000;
//
monitor.addEventListener(StatusEvent.STATUS,onConnection);
//
function onConnection(e:Event = null):void
{
trace("onConnection")
}
//
monitor.start();
trace(monitor)
}
缺少什么?谢谢.乌利
推荐答案
需要添加aircore.swc
You need to add the aircore.swc
转到文件->ActionScript 设置
Go to File->ActionScript Settings
在库路径选项卡上,单击 + 图标(添加新路径),然后单击 Flash 图标(浏览至 SWC).
On the Library Path tab, click the + icon (Add New Path) and then click the Flash icon (Browse To SWC).
然后您需要浏览到安装 Flash CS5 的位置并转到 AIK2.5/frameworks/libs/air/并选择 aircore.swc
You then need to browse to the location where Flash CS5 is installed and go to AIK2.5/frameworks/libs/air/ and select the aircore.swc
这篇关于Adobe Air - 检查互联网连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!