[AS 2.0] for..in 구문을 이용해서 속성값 확인
AS 2.0에서 for..in 구문을 이용해서 모든 속성값을 확인하는 방법.
//CheckProperty.as
class CheckProperty{
//Constructor
function CheckProperty(){
trace("===== CheckProperty Constructor Load Success =====");
}
function startCheckProperty(){
for(var property in arguments[0]){
trace(property + " : (" + typeof arguments[0][property] + ") ==> " + arguments[0][property]);
}
}
}
//CheckProperty.fla var myCheckProperty:CheckProperty = new CheckProperty(); myCheckProperty.startCheckProperty(this); //Output //===== CheckProperty Constructor Load Success ===== //myCheckProperty : (object) ==> [object Object] //$version : (string) ==> WIN 9,0,45,0
Ball = function(){
this.radius = arguments[0];
this.color = arguments[1];
this.xPosition = arguments[2];
this.yPosition = arguments[3];
}
myBall = new Ball(10, 0xFF0000, 50, 15);
for(var property in myBall){
trace(property + " : (" + typeof myBall[property] + ") ==> " + myBall[property]);
}
// ---------- 결과 값 ----------
// yPosition : (number) ==> 15
// xPosition : (number) ==> 59
// color : (number) ==> 16711680
// radius : (number) ==> 10
