Solved

Can you trace the properties of an object using AS3?

Posted on 2008-10-15
2
1,995 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
2 Comments
 
LVL 4

Accepted Solution

by:
MattKenefick earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop Ads in Browser Google Chrome 3 538
Action Script commands 5 234
Flash builder 4.13 list scroller does not work 1 37
Adobe Products Forum? 3 147
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now