| window.runtime 属性 | window.runtime.flash.net.URLRequestMethod |
| 继承 | URLRequestMethod Object |
| 运行时版本: | 1.0 |
POST 方法还是 GET 方法。
另请参见
| 常量 | 定义方 | ||
|---|---|---|---|
| DELETE : String = "DELETE" [静态]
指定 URLRequest 对象为 DELETE。 | URLRequestMethod | ||
| GET : String = "GET" [静态]
指定 URLRequest 对象为 GET。 | URLRequestMethod | ||
| HEAD : String = "HEAD" [静态]
指定 URLRequest 对象为 HEAD。 | URLRequestMethod | ||
| OPTIONS : String = "OPTIONS" [静态]
指定 URLRequest 对象为 OPTIONS。 | URLRequestMethod | ||
| POST : String = "POST" [静态]
指定 URLRequest 对象为 POST。 | URLRequestMethod | ||
| PUT : String = "PUT" [静态]
指定 URLRequest 对象为 PUT。 | URLRequestMethod | ||
| DELETE | 常量 |
| GET | 常量 |
| HEAD | 常量 |
| OPTIONS | 常量 |
| POST | 常量 |
static const POST:String = "POST"| 运行时版本: | 1.0 |
指示 URLRequest 对象是一个 POST。
注意:使用 navigateToURL() 函数时,运行时将使用 POST 方法的 URLRequest(其 method 属性设置为 URLRequestMethod.POST)视为使用 GET 方法。
| PUT | 常量 |
注意:要运行此示例,请将名为 example.txt 的文件与 HTML 文件放在同一目录下。该文件应当是一个包含几个词或几行文字的简单文本文件。此外,还要将 AIRAliases.js 文件添加到该目录。
该示例代码执行以下操作:
init() 函数创建名为 loader 的 URLLoader 实例。loader 对象被传递给 configureListeners() 方法,该方法可为每个受支持的 URLLoader 事件添加侦听器。request 的 URLRequest 实例,这指定了要加载文件的名称。method 属性设置为 URLRequestMethod.POST。request 对象被传递给 loader.load(),该方法可加载文本文件。complete 事件,进而触发 completeHandler() 方法。completeHandler() 方法只跟踪 data 属性,即文本文件的内容。注意:要测试此示例,请执行以下操作:
URLRequest() 构造函数指向有效的 URL 和端口。
<html>
<head>
<script src="AIRAliases.js" />
<script>
function init() {
var loader = new air.URLLoader();
configureListeners(loader);
var request = new air.URLRequest("http://www.example.com/");
request.method = air.URLRequestMethod.POST;
loader.load(request);
}
function configureListeners(dispatcher) {
dispatcher.addEventListener(air.Event.COMPLETE, completeHandler);
dispatcher.addEventListener(air.Event.OPEN, openHandler);
dispatcher.addEventListener(air.ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(air.SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(air.HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function completeHandler(event) {
var loader = air.URLLoader(event.target);
air.trace("completeHandler: " + loader.data);
}
function openHandler(event) {
air.trace("openHandler: " + event);
}
function progressHandler(event) {
air.trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
function securityErrorHandler(event) {
air.trace("securityErrorHandler: " + event);
}
function httpStatusHandler(event) {
air.trace("httpStatusHandler: " + event);
}
function ioErrorHandler(event) {
air.trace("ioErrorHandler: " + event);
}
</script>
</head>
<body onload='init()'>
</body>
</html>