AS3 Class Enumeration
筆記筆記..
一般在 AS3 要列舉 Object 的 properties 時,通常會用下面這種寫法:
不過在處理 VO (Value Object) 時則會出問題,因為它是 Class,後來在這篇文章找到解法:
一般在 AS3 要列舉 Object 的 properties 時,通常會用下面這種寫法:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get an XML description of this class | |
//and return the variable types as XMLList with e4x | |
var varList:XMLList = flash.utils.describeType(VO)..variable; | |
for(var i:int; i < varList.length(); i++){ | |
//Show the name and the value | |
trace(varList[i].@name+':'+ VO[varList[i].@name]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var key:String in object) | |
{ | |
trace(key+':'+ object[key]); | |
} |
留言
張貼留言