Solved

Can you trace the properties of an object using AS3?

Posted on 2008-10-15
2
2,005 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

740 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