ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
URLRequestMethod

Package | flash.net
Class | public final class URLRequestMethod
Inheritance | URLRequestMethod Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The URLRequestMethod class provides values that specify whether the URLRequest object should use the `POST` method or the `GET` method when sending data to a server.

View the examples

See also

URLRequest
URLVariables

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Public Constants

| Constant | Defined By
--- | --- | ---
|  | GET : String = "GET" [static] Specifies that the URLRequest object is a GET. | URLRequestMethod
|  | POST : String = "POST" [static] Specifies that the URLRequest object is a POST. | URLRequestMethod

Constant Detail

GET | Constant

`public static const GET:String = "GET"`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Specifies that the URLRequest object is a `GET`.

POST | Constant |

`public static const POST:String = "POST"`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Specifies that the URLRequest object is a `POST`.

Examples How to use examples
URLRequestMethodExample.as
The following example loads and displays the data found in a local text file. It also traces event handling information.

Note:To run this example, put a file named example.txt in the same directory as your SWF file. That file should be a simple text file containing a few words or lines of text.

The example code does the following:

1. The constructor function creates a URLLoader instance named `loader`.
2. The `loader` object is passed to the `configureListeners()` method, which adds listeners for each of the supported URLLoader events.
3. A URLRequest instance named `request` is created, which specifies name of the file to be loaded.
4. The `method` property of the request is set to `URLRequestMethod.POST`.
5. The `request` object is then passed to `loader.load()`, which loads the text file.
6. When the URLLoader has finished loading the text file the `Event.COMPLETE` event fires, triggering the `completeHandler()` method. The `completeHandler()` method simply traces the `data` property, the contents of the text file.

    package {
        import flash.display.Sprite;
        import flash.events.*;
        import flash.net.*;

        public class URLRequestMethodExample extends Sprite {

            public function URLRequestMethodExample() {
                var loader:URLLoader = 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);
            }
        }
    }

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00