PDA

View Full Version : Reading all properties of an object/event


FlashBulb
03-05-2008, 06:23 PM
I've had this issue a number of times. When testing code, there are times when I'd like to trace all properties (and more?) of a certain thing in the code.

I use this:
var newObj:Object = {prop1:12, prop2:"as", prop3:true};
for(var i:String in newObj){
trace(i + ": " + newObj[i]);
}

//returns:

//prop1: 12
//prop3: true
//prop2: as

But when I try to use it on some other things, it doesn't work. Isn't EVERYTHING an Object?

For instance, I was looking at some code from the Help - a function (mouseMoveHandler) that takes the parameter 'event:MouseEvent'.

I wanted to see what properties (such as currentTarget) that I could use within MouseEvent, but the loop described above doesn't show me what's available.

Is there another method I can use to search through all properties of things?

FlashBulb
04-02-2008, 03:46 PM
I just want to be able to see all properties of as LineSeries Object. How can I do that?

amarghosh
04-03-2008, 05:15 AM
for .. in syntax works for only dynamic properties.

use flash.utils.describeType() (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#describeType()) function for fixed properties.