Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created August 9, 2011 15:17
Show Gist options
  • Save rafaelrinaldi/1134335 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/1134335 to your computer and use it in GitHub Desktop.
List all properties and values from a object.
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