Package | flash.net |
Class | public final class URLRequestMethod |
Inheritance | URLRequestMethod ![]() |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
POST
method or the GET
method when sending data to a server.
Related API Elements
Property | Defined By | ||
---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object |
Method | Defined By | ||
---|---|---|---|
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object |
Constant | Defined By | ||
---|---|---|---|
DELETE : String = "DELETE" [static]
Specifies that the URLRequest object is a DELETE. | URLRequestMethod | ||
GET : String = "GET" [static]
Specifies that the URLRequest object is a GET. | URLRequestMethod | ||
HEAD : String = "HEAD" [static]
Specifies that the URLRequest object is a HEAD. | URLRequestMethod | ||
OPTIONS : String = "OPTIONS" [static]
Specifies that the URLRequest object is OPTIONS. | URLRequestMethod | ||
POST : String = "POST" [static]
Specifies that the URLRequest object is a POST. | URLRequestMethod | ||
PUT : String = "PUT" [static]
Specifies that the URLRequest object is a PUT. | URLRequestMethod |
DELETE | Constant |
public static const DELETE:String = "DELETE"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 |
Specifies that the URLRequest object is a DELETE
.
GET | Constant |
public static const GET:String = "GET"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Specifies that the URLRequest object is a GET
.
HEAD | Constant |
public static const HEAD:String = "HEAD"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 |
Specifies that the URLRequest object is a HEAD
.
OPTIONS | Constant |
public static const OPTIONS:String = "OPTIONS"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 |
Specifies that the URLRequest object is OPTIONS
.
POST | Constant |
public static const POST:String = "POST"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Specifies that the URLRequest object is a POST
.
Note: For content running in Adobe AIR, when
using the navigateToURL()
function, the runtime
treats a URLRequest that uses the POST method (one that has its method
property set to
URLRequestMethod.POST
) as using the GET method.
PUT | Constant |
public static const PUT:String = "PUT"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 |
Specifies that the URLRequest object is a PUT
.
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:
- The constructor function creates a URLLoader instance named
loader
. - The
loader
object is passed to theconfigureListeners()
method, which adds listeners for each of the supported URLLoader events. - A URLRequest instance named
request
is created, which specifies name of the file to be loaded. - The
method
property of the request is set toURLRequestMethod.POST
. - The
request
object is then passed toloader.load()
, which loads the text file. - When the URLLoader has finished loading the text file the
Event.COMPLETE
event fires, triggering thecompleteHandler()
method. ThecompleteHandler()
method simply traces thedata
property, the contents of the text file.
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); } } }
Thu Dec 4 2014, 05:50 PM -08:00