[AS 2.0] for..in 구문을 이용해서 속성값 확인

ActionScript 2.0 — Tags: , — Siaa @ 11:17 am

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  
  • Share/Bookmark

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 blog.flasia.com | powered by WordPress with Barecity