パッケージトップレベル
public class arguments
継承arguments Inheritance Object

arguments オブジェクトは、関数の引数を保存したり、引数にアクセスする場合に使用されます。関数の本体に含まれる場合、arguments オブジェクトにはローカルの arguments 変数を使用してアクセスできます。

引数は配列要素として格納されます。最初の引数は arguments[0] として、2 番目の引数は arguments[1] のようにアクセスされます。arguments.length プロパティは、関数に渡される引数の数を示します。関数で宣言された数と異なる数の引数が渡される場合もあります。

以前のバージョンの ActionScript とは異なり、ActionScript 3.0 には arguments.caller プロパティがありません。現在の関数を呼び出した関数への参照を取得するには、その関数への参照を引数として渡す必要があります。このテクニックの例については、arguments.callee の例を参照してください。

ActionScript 3.0 では、新しく ...(rest) キーワードが含まれています。arguments クラスではなく、このステートメントを使用することをお勧めします。

例の表示

関連項目

...(rest)
Function


パブリックプロパティ
 プロパティ定義
  callee : Function
現在実行中の関数への参照です。
arguments
 Inheritedconstructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクタ関数への参照です。
Object
  length : Number
関数に渡される引数の数です。
arguments
 Inheritedprototype : Object
[static] クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
Object
パブリック Methods
 メソッド定義
 Inherited
指定されたプロパティがオブジェクトに定義されているかどうかを示します。
Object
 Inherited
Object クラスのインスタンスが、パラメータとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 Inherited
指定されたプロパティが存在し、列挙できるかどうかを示します。
Object
 Inherited
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 Inherited
指定されたオブジェクトのストリング表現を返します。
Object
 Inherited
指定されたオブジェクトのプリミティブな値を返します。
Object
プロパティの詳細
calleeプロパティ
public var callee:Function

現在実行中の関数への参照です。



The following code shows how to get a reference to the function that calls the function named secondFunction(). The firstFunction() function has the Boolean argument of true to demonstrate that secondFunction() successfully calls firstFunction() and to prevent an infinite loop of each function calling the other.

Because the callSecond parameter is true, firstFunction() calls secondFunction() and passes a reference to itself as the only argument. The function secondFunction() receives this argument and stores it using a parameter named caller, which is of data type Function. From within secondFunction(), the caller parameter is then used to call the firstFunction function, but this time with the callSecond argument set to false.

When execution returns to firstFunction(), the trace() statement is executed because callSecond is false.

 package { import flash.display.Sprite;
    
    public class ArgumentsExample extends Sprite { private var count:int = 1;
        
        public function ArgumentsExample() { firstFunction(true); }

        public function firstFunction(callSecond:Boolean) { trace(count + ": firstFunction"); if(callSecond) { secondFunction(arguments.callee); } else { trace("CALLS STOPPED"); } }

        public function secondFunction(caller:Function) { trace(count + ": secondFunction\n"); count++; caller(false); } } }

lengthプロパティ 
public var length:Number

関数に渡される引数の数です。関数で宣言された数よりも増減する場合があります。


The following example shows uses for various arguments properties, such as callee and length.
 package { import flash.display.Sprite;
    
    public class ArgumentsExample extends Sprite { public function ArgumentsExample() { println("Hello World"); }
        
        public function println(str:String):void { trace(arguments.callee == this.println); // true trace(arguments.length);                 // 1 trace(arguments[0]);                     // Hello World trace(str);                                // Hello World } } }