Created
August 9, 2011 15:17
-
-
Save rafaelrinaldi/1134335 to your computer and use it in GitHub Desktop.
List all properties and values from a object.
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
package com.rafaelrinaldi.string | |
{ | |
import flash.utils.describeType; | |
/** | |
* | |
* List all properties and values from a object. | |
* | |
* @author Rafael Rinaldi (rafaelrinaldi.com) | |
* @since Aug 9, 2011 | |
* | |
*/ | |
public function getPropertyStack( p_target : Object ) : String | |
{ | |
var stack : String; | |
var node : XML; | |
var key : String; | |
var count : int = 0; | |
const list : XML = describeType(p_target); | |
const variables : XMLList = list.child("variable"); | |
const name : String = list.attribute("name"); | |
stack = "[object " + name.substring(name.lastIndexOf(":") + 1, name.length) + "]"; | |
for each(node in variables) { | |
key = node.attribute("name"); | |
if(count == 0) stack += " "; | |
stack += key + ": " + p_target[key]; | |
if(count < variables.length() - 1) stack += ", "; | |
++count; | |
} | |
return stack; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment