Solved

Can you trace the properties of an object using AS3?

Posted on 2008-10-15
2
2,006 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

690 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