| パッケージ | flash.net |
| public final class URLRequestMethod | |
| 継承 | URLRequestMethod Object |
POST または GET のどちらのメソッドを使用するかを指定する値を提供します。
関連項目
| 定数 | 定義 | ||
|---|---|---|---|
| GET : String = "GET" [static]
URLRequest オブジェクトが
GET であることを指定します。 | URLRequestMethod | ||
| POST : String = "POST" [static]
URLRequest オブジェクトが
POST であることを指定します。 | URLRequestMethod | ||
| GET | 定数 |
public static const GET:String = "GET"
URLRequest オブジェクトが GET であることを指定します。
| POST | 定数 |
public static const POST:String = "POST"
URLRequest オブジェクトが POST であることを指定します。
メモ : この例を実行するには、example.txt という名前のファイルを SWF ファイルと同じディレクトリに配置します。このファイルは、いくつかの単語またはテキスト行を含む 単純なテキストファイルです。
コード例では、次の処理が実行されます。
loader という URLLoader インスタンスを作成します。loader オブジェクトが configureListeners() メソッドに渡され、
サポートされる各 URLLoader イベントにリスナーを追加します。request という URLRequest インスタンスが作成されます。これは、ロードされるファイルの名前を指定します。method プロパティは、URLRequestMethod.POST に設定されます。request オブジェクトが、テキストファイルをロードする loader.load() に渡されます。Event.COMPLETE イベントが発生し、
completeHandler() メソッドがトリガされます。completeHandler() メソッドは、単純に
テキストファイルのコンテンツである data プロパティをトレースします。
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);
}
}
}