?
Solved

Can you trace the properties of an object using AS3?

Posted on 2008-10-15
2
Medium Priority
?
2,007 Views
Last Modified: 2013-11-11
Hi -

The title pretty much sums it up. I'm trying to build a function that will take an object and trace out the property name/value pair for each property in the object. I'm using AS3 and the AS3 methods don't seem to work any longer. Any help would be appreciated.
0
Comment
Question by:katyjack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
MattKenefick earned 2000 total points
ID: 22731978
function analyze(_obj, lastItem:String = ''):void {
      var item:Object;
      
      switch (typeof(_obj)){
            case "array":
                  write("<array>");
                  write(_obj.toString());
                  for (item in _obj){
                        analyze(item,item.toString());
                  };
                  write("</array>");
            break;
            case "xml":
                  write("<xml>");
                  write(_obj);
                  write("</xml>");
            break;
            case "object":
                  write("<object>");
                  write(_obj.toString());
                  for (item in _obj){
                        analyze(_obj[item],item.toString());
                  };
                  write("</object>");
            break;
            default:
                  write( lastItem + "::" + _obj + " (" + typeof(_obj) + ")");
                  lastItem='';
            break;
      };
}
function write(_obj):void{
      trace(_obj);
}
 
var test = new Object();
test.Property1 = 'yeah'
test.Property2 = 'im great';
test.Property3 = 'bye now';

analyze(test);
0
 

Author Closing Comment

by:katyjack
ID: 31506440
That's a lot more complicated than a for...in group!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question