| 言語バージョン: | ActionScript 3.0 |
| ランタイムバージョン: | AIR 1.0 Flash Player 9 |
URLRequestMethod クラスは、URLRequest オブジェクトがデータをサーバーに送信するときに
POST または
GET のどちらのメソッドを使用するかを指定する値を提供します。
例を表示
public static const DELETE:String = "DELETE"| 言語バージョン: | ActionScript 3.0 |
URLRequest オブジェクトが DELETE であることを指定します。
public static const GET:String = "GET"| 言語バージョン: | ActionScript 3.0 |
| ランタイムバージョン: | AIR 1.0 Flash Player 9 |
URLRequest オブジェクトが GET であることを指定します。
public static const HEAD:String = "HEAD"| 言語バージョン: | ActionScript 3.0 |
URLRequest オブジェクトが HEAD であることを指定します。
public static const OPTIONS:String = "OPTIONS"| 言語バージョン: | ActionScript 3.0 |
URLRequest オブジェクトが OPTIONS であることを指定します。
public static const POST:String = "POST"| 言語バージョン: | ActionScript 3.0 |
| ランタイムバージョン: | AIR 1.0 Flash Player 9 |
URLRequest オブジェクトが POST であることを指定します。
メモ:Adobe AIR で実行中のコンテンツの場合、 で navigateToURL() 関数を使用すると、ランタイムでは、POST メソッドを使用する URLRequest(method プロパティが URLRequestMethod.POST に設定されているもの)は、GET メソッドとして処理されます。
public static const PUT:String = "PUT"| 言語バージョン: | ActionScript 3.0 |
URLRequest オブジェクトが PUT であることを指定します。
次の例では、ローカルテキストファイルで検出されたデータをロードして表示します。また、イベント処理情報も出力します。
メモ : この例を実行するには、example.txt ファイルを SWF ファイルと同じディレクトリに配置します。このファイルは、いくつかの単語またはテキスト行を含む単純なテキストファイルとする必要があります。
コード例では、次の処理が実行されます。
- コンストラクタ関数は
loader という URLLoader インスタンスを作成します。 loader オブジェクトが configureListeners() メソッドに渡されます。このメソッドは、サポートされる各 URLLoader イベントのリスナーを追加します。request という URLRequest インスタンスが作成されます。これは、ロードされるファイルの名前を指定します。- 要求の
method プロパティは、URLRequestMethod.POST に設定されます。 - 次に
request オブジェクトが、テキストファイルを読み込む loader.load() に渡されます。 - URLLoader によるテキストファイルのロードが終了すると、
Event.COMPLETE event イベントが発生し、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);
}
}
}
© 2009 Adobe Systems Incorporated. All rights reserved.
Thu Mar 19 2009, 08:51 PM -07:00 現在のページ: http://livedocs.adobe.com/flex/3_jp/langref/flash/net/URLRequestMethod.html