This page was saved using jaction on 2006-09-04 8:33:26.
Address: http://flexdocs.kr/docs/flex2/langref/arguments.html
Title: arguments (Flex™ 2 레퍼런스 가이드)  •  Size: 21260
Package톱 레벨
Classpublic class arguments
Inheritancearguments Inheritance Object

arguments object는, 함수의 인수를 보존하거나 인수에 액세스 하는 경우에 사용됩니다. 함수의 본체에 포함되는 경우, arguments object에는 로컬의 arguments 변수를 사용해 액세스 할 수 있습니다.

인수는 배열 엘리먼트로서 보존되어 최초의 인수는 arguments[0] 으로서 2 번째의 인수는 arguments[1] 과 같이 액세스 됩니다. arguments.length property는, 함수에게 건네지는 인수의 수를 나타냅니다. 함수로 선언된 수와 다른 수의 인수가 건네받는 경우도 있습니다.

이전의 버젼의 ActionScript 과는 달리, ActionScript 3.0 에는 arguments.caller property가 없습니다. 현재의 함수를 호출한 함수에의 참조를 취득하려면 , 그 함수에의 참조를 인수로서 건네줄 필요가 있습니다. 이 테크닉의 예에 대해서는,arguments.callee 의 예를 참조해 주세요.

ActionScript 3.0 에서는, 새롭고 ...(rest) 키워드가 포함되어 있습니다. arguments 클래스는 아니고, 이 명령문(statement)를 사용하는 것을 추천합니다.

View the examples

See also

...(rest)
Function


Public property
 property정의
  callee : Function
현재 실행중의 함수에의 참조입니다.
arguments
 Inheritedconstructor : Object
특정의 object 인스턴스의 클래스 object 또는 constructor    함수에의 참조입니다.
Object
  length : Number
함수에게 건네지는 인수의 수입니다.
arguments
 Inheritedprototype : Object
[static] 클래스 또는 함수 object의 prototype object에의 참조입니다.
Object
Public Methods
 Methods정의
 InheritedhasOwnProperty (name:String ):Boolean
object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다.
Object
 InheritedisPrototypeOf (theClass:Object ):Boolean
Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다.
Object
 InheritedpropertyIsEnumerable (name:String ):Boolean
지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다.
Object
 InheritedsetPropertyIsEnumerable (name:String , isEnum:Boolean = true):void
루프 처리에 대한 다이나믹 property의 가용성을 설정합니다.
Object
 InheritedtoString ():String
지정된 object의 string 표현을 돌려줍니다.
Object
 InheritedvalueOf ():Object
지정된 object의 원시적치를 돌려줍니다.
Object
property의 상세
calleeproperty
public var callee:Function

현재 실행중의 함수에의 참조입니다.


Example
다음의 코드는,secondFunction() 라는 이름의 함수를 호출하는 함수에의 참조를 취득합니다. firstFunction() 함수는, 불 인수 true 를 가져, secondFunction()firstFunction() 를 정상적으로 호출하고 있는 것을 나타내, 각 함수가 한편의 함수를 서로 호출하는 것에 의한 엔들레스 루프를 막습니다.

callSecond Parameters가 true 이기 (위해)때문에,firstFunction()secondFunction() 를 호출해, 자신에게로의 참조를 유일한 인수로서 건네줍니다. 함수 secondFunction() 는, 데이터형이 Function 로,caller 라는 이름의 Parameters를 사용해, 이 인수를 받아, 보존합니다. 다음에,secondFunction() 내로부터, caller Parameters로 firstFunction 함수를 호출합니다. 다만, 이 때,callSecond 인수는 false 로 설정됩니다.

실행이 firstFunction() 에 돌아오면,trace() 명령문(statement)가 실행됩니다. 이것은 callSecondfalse 이기 (위해)때문에입니다.

  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);
        }        
    }
}

lengthproperty 
public var length:Number

함수에게 건네지는 인수의 수입니다. 함수로 선언된 수보다 증감하는 경우가 있습니다.

Examples

다음의 예는,calleelength 등의 다양한 arguments property의 사용법을 나타내고 있습니다.
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
        }
    }
}






 

코멘트가 추가되었을 경우, 메일로 받기. | 코멘트 리포트

현재의 페이지: http://flexdocs.kr/docs/flex2/langref/arguments.html