window.runtime 属性window.runtime.flash.net.URLRequestMethod
继承URLRequestMethod Inheritance Object
运行时版本:  1.0

URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时,URLRequest 对象应使用 POST 方法还是 GET 方法。

查看示例

另请参见

URLRequest
URLVariables


属性
 属性定义方
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 Inheritedprototype : Object
[静态] 对类或函数对象的原型对象的引用。
Object
公共方法
 方法定义方
 Inherited
hasOwnProperty(name:String):Boolean
指示对象是否已经定义了指定的属性。
Object
 Inherited
isPrototypeOf(theClass:Object):Boolean
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
propertyIsEnumerable(name:String):Boolean
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
设置循环操作动态属性的可用性。
Object
 Inherited
toString():String
返回指定对象的字符串表示形式。
Object
 Inherited
valueOf():Object
返回指定对象的原始值。
Object
常量
 常量定义方
  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常量
static const DELETE:String = "DELETE"
运行时版本:  1.0

指定 URLRequest 对象为 DELETE

GET常量 
static const GET:String = "GET"
运行时版本:  1.0

指示 URLRequest 对象是一个 GET

HEAD常量 
static const HEAD:String = "HEAD"
运行时版本:  1.0

指定 URLRequest 对象为 HEAD

OPTIONS常量 
static const OPTIONS:String = "OPTIONS"
运行时版本:  1.0

指定 URLRequest 对象为 OPTIONS

POST常量 
static const POST:String = "POST"
运行时版本:  1.0

指示 URLRequest 对象是一个 POST

注意:使用 navigateToURL() 函数时,运行时将使用 POST 方法的 URLRequest(其 method 属性设置为 URLRequestMethod.POST)视为使用 GET 方法。

PUT常量 
static const PUT:String = "PUT"
运行时版本:  1.0

指定 URLRequest 对象为 PUT

示例
URLRequestMethodExample.as

下例加载并显示在本地文本文件中找到的数据。它还会跟踪事件处理信息。

注意:要运行此示例,请将名为 example.txt 的文件与 HTML 文件放在同一目录下。该文件应当是一个包含几个词或几行文字的简单文本文件。此外,还要将 AIRAliases.js 文件添加到该目录。

该示例代码执行以下操作:

  1. init() 函数创建名为 loader 的 URLLoader 实例。
  2. loader 对象被传递给 configureListeners() 方法,该方法可为每个受支持的 URLLoader 事件添加侦听器。
  3. 创建了一个名为 request 的 URLRequest 实例,这指定了要加载文件的名称。
  4. 请求的 method 属性设置为 URLRequestMethod.POST
  5. 然后,request 对象被传递给 loader.load(),该方法可加载文本文件。
  6. URLLoader 加载文本文件完毕时将引发 complete 事件,进而触发 completeHandler() 方法。completeHandler() 方法只跟踪 data 属性,即文本文件的内容。

注意:要测试此示例,请执行以下操作:

  1. 将 AIRAliases.js 文件添加到项目目录。
  2. 更改代码,使 URLRequest() 构造函数指向有效的 URL 和端口。
  3. 为该项目创建应用程序描述符文件,并使用 ADL 测试该项目。


<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>