| パッケージ | トップレベル |
| public class arguments | |
| 継承 | arguments Object |
引数は配列要素として格納されます。最初の引数は arguments[0] として、2 番目の引数は arguments[1] のようにアクセスされます。arguments.length プロパティは、関数に渡される引数の数を示します。関数で宣言された数と異なる数の引数が渡される場合もあります。
以前のバージョンの ActionScript とは異なり、ActionScript 3.0 には arguments.caller プロパティがありません。現在の関数を呼び出した関数への参照を取得するには、その関数への参照を引数として渡す必要があります。このテクニックの例については、arguments.callee の例を参照してください。
ActionScript 3.0 では、新しく ...(rest) キーワードが含まれています。arguments クラスではなく、このステートメントを使用することをお勧めします。
関連項目
| プロパティ | 定義 | ||
|---|---|---|---|
| callee : Function
現在実行中の関数への参照です。
| arguments | ||
![]() | constructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクタ関数への参照です。
| Object | |
| length : Number
関数に渡される引数の数です。
| arguments | ||
![]() | prototype : Object
[static]
クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
| Object | |
| callee | プロパティ |
public var callee:Function現在実行中の関数への参照です。
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関数に渡される引数の数です。関数で宣言された数よりも増減する場合があります。
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 } } }