| 包 | flash.net |
| 类 | public final class URLRequestMethod |
| 继承 | URLRequestMethod Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
POST 方法还是 GET 方法。
相关 API 元素
公共常量
| 常量 | 由以下参数定义 | ||
|---|---|---|---|
| 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 | 常量 |
public static const DELETE:String = "DELETE"| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0 |
指定 URLRequest 对象为 DELETE。
GET | 常量 |
public static const GET:String = "GET"| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
表示 URLRequest 对象是一个 GET。
HEAD | 常量 |
public static const HEAD:String = "HEAD"| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0 |
指定 URLRequest 对象为 HEAD。
OPTIONS | 常量 |
public static const OPTIONS:String = "OPTIONS"| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0 |
指定 URLRequest 对象为 OPTIONS。
POST | 常量 |
public static const POST:String = "POST"| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
表示 URLRequest 对象是一个 POST。
注意:对于在 Adobe AIR 中运行的内容,当使用 navigateToURL() 函数时,运行时将使用 POST 方法的 URLRequest(其 method 属性设置为 URLRequestMethod.POST)视为使用 GET 方法。
PUT | 常量 |
示例 如何使用本示例
URLRequestMethodExample.as
下例加载并显示在本地文本文件中找到的数据。它还会跟踪事件处理信息。
注意:要运行此示例,请将名为 example.txt 的文件与 SWF 文件放在同一目录下。该文件应当是一个包含几个词或几行文字的简单文本文件。
该示例代码执行以下操作:
- 构造函数创建了一个名为
loader。 loader对象被传递给configureListeners()方法,该方法可为每个受支持的 URLLoader 事件添加侦听器。- 创建了一个名为
request的 URLRequest 实例,这指定了要加载文件的名称。 - 请求的
method属性设置为URLRequestMethod.POST。 - 然后,
request对象被传递给loader.load(),该方法可加载文本文件。 - 当 URLLoader 完成文本文件的加载时,将引发
Event.COMPLETE事件,同时触发completeHandler()方法。completeHandler()方法只跟踪data属性,即文本文件的内容。
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class URLRequestMethodExample extends Sprite {
private var loader:URLLoader;
public function URLRequestMethodExample() {
loader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("example.txt");
request.method = URLRequestMethod.POST;
loader.load(request);
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性