Hi David,
As I was recently reminded, you can only loop over properties this
was when they are dynamically created, as in your first example. To
enumerate the declared properties of your custom class, I believe you
need to use the describeType() or getClassInfo() methods. See
'performing object introspection' in the docs for details on this.
Cheers,
Lach
On 18/12/2006, at 9:20 AM, David Harris wrote:
Hi Guys,
Anyone know how I loop over properties of a Class that extends
"Obejct"
Here is an example of what I mean...
if I go:
var oThisObject:Object = {one:"one",two:"two",three:"Three"};
I can do this:
for(var s:String in oThisObject){
trace(s);
}
and will trace out "one,two,three"
If I create a class"
package somePackage
{
[Bindable]
public class MyCustomClass extends Object
{
public var one:String = "one";
public var two:String = "two";
public var three:String = "three";
}
}
and then have
var oThisObject:MyCustomClass = new MyCustomClass();
I can't do this:
for(var s:String in oThisObject){
trace(s);
}
and get any results...
...also the "toString" breaks...
I want to be able to do the second option as the properties on the
Class will be changed and added to, i would lke to refer to them
dynamically...
Cheers,
David