Solved

Can you trace the properties of an object using AS3?

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

707 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

17 Experts available now in Live!

Get 1:1 Help Now