| Pacchetto | flash.net |
| Classe | public final class URLRequestMethod |
| Ereditarietà | URLRequestMethod Object |
| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0, Flash Player 9, Flash Lite 4 |
POST o il metodo GET quando invia dati a un server.
Elementi API correlati
| Costante | Definito da | ||
|---|---|---|---|
| DELETE : String = "DELETE" [statico]
Specifica che l'oggetto URLRequest è di tipo DELETE. | URLRequestMethod | ||
| GET : String = "GET" [statico]
Specifica che l'oggetto URLRequest è di tipo GET. | URLRequestMethod | ||
| HEAD : String = "HEAD" [statico]
Specifica che l'oggetto URLRequest è di tipo HEAD. | URLRequestMethod | ||
| OPTIONS : String = "OPTIONS" [statico]
Specifica che l'oggetto URLRequest è di tipo OPTIONS. | URLRequestMethod | ||
| POST : String = "POST" [statico]
Specifica che l'oggetto URLRequest è di tipo POST. | URLRequestMethod | ||
| PUT : String = "PUT" [statico]
Specifica che l'oggetto URLRequest è di tipo PUT. | URLRequestMethod | ||
DELETE | Costante |
public static const DELETE:String = "DELETE"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0 |
Specifica che l'oggetto URLRequest è di tipo DELETE.
GET | Costante |
public static const GET:String = "GET"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Specifica che l'oggetto URLRequest è di tipo GET.
HEAD | Costante |
public static const HEAD:String = "HEAD"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0 |
Specifica che l'oggetto URLRequest è di tipo HEAD.
OPTIONS | Costante |
public static const OPTIONS:String = "OPTIONS"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0 |
Specifica che l'oggetto URLRequest è di tipo OPTIONS.
POST | Costante |
public static const POST:String = "POST"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Specifica che l'oggetto URLRequest è di tipo POST.
Nota: per i contenuti in esecuzione in Adobe AIR, quando utilizza la funzione navigateToURL(), il runtime considera un oggetto URLRequest che utilizza il metodo POST (ovvero la cui proprietà method è impostata su URLRequestMethod.POST) come se utilizzasse il metodo GET.
PUT | Costante |
public static const PUT:String = "PUT"| Versione linguaggio: | ActionScript 3.0 |
| Versioni runtime: | AIR 1.0 |
Specifica che l'oggetto URLRequest è di tipo PUT.
Nota: per provare l'esempio, collocate un file denominato example.txt nella stessa directory del file SWF. Deve trattarsi di un semplice file di testo che contiene poche parole o righe di testo.
Il codice di esempio esegue le seguenti operazioni:
- La funzione di costruzione crea un'istanza URLLoader di nome
loader. - L'oggetto
loaderviene passato al metodoconfigureListeners()che aggiunge i listener per ognuno degli eventi URLLoader supportati. - Viene creata un'istanza URLRequest di nome
request, che specifica il nome del file da caricare. - La proprietà
methoddella richiesta viene impostata suURLRequestMethod.POST. - Quindi, l'oggetto
requestviene passato aloader.load(), che carica il file di testo. - Quando URLLoader ha terminato il caricamento del file di testo, si attiva l'evento
Event.COMPLETE, che a sua volta attiva il metodocompleteHandler(). Il metodocompleteHandler()traccia semplicemente la proprietàdata, il contenuto del file di testo.
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, 02:44 PM Z
Nascondi proprietà pubbliche ereditate
Mostra proprietà pubbliche ereditate