i have another question:
when I do the following:
for(var prop in instancOfB){
//gets here only once as if instancOfB has only one member
}
bur if I do the following:
for each(var prop in instancOfB){
//will show the values of all props
}
the problem is that for each will not give me the prop name but only
the value. a simple "for" gives me a name and value but fails to show
all props.
--- In [email protected], "leo4beer" <[EMAIL PROTECTED]> wrote:
>
> Thanks Peter, that was the problem.
>
>
> --- In [email protected], "Peter Farland" <pfarland@> wrote:
> >
> >
> >
http://livedocs.macromedia.com/flex/2/langref/statements.html#for_each..
> > in
> >
> > Note:
> >
> > The for each..in statement iterates only through the dynamic
properties
> > of an object, not the fixed properties
> >
> > Also note that the "dynamic" behavior of a type is not inherited.
> >
> > You can use describeType() to get an XML description of a type to see
> > concrete properties on any given type:
> >
> >
http://livedocs.macromedia.com/flex/2/langref/flash/utils/package.html#d
> > escribeType()
> >
> > The utility class mx.utils.ObjectUtil.getClassInfo() does exactly this
> > and in the result Object it includes a "properties" method that
includes
> > the names of all of the fixed and dynamic properties for an
instance of
> > a type to help you iterate types in a generic manner.
> >
> >
> >
> > ________________________________
> >
> > From: [email protected]
[mailto:[EMAIL PROTECTED] On
> > Behalf Of leo4beer
> > Sent: Monday, December 11, 2006 3:45 PM
> > To: [email protected]
> > Subject: [flexcoders] problem with a "for each" loop
> >
> >
> >
> > Hi, I got a problem with a "for each" loop.
> >
> > I have a class (B), B has a long inheritance chain where the oldest
> > ancestor is class A.
> > Class A does not declare an extension of any other class therefore I
> > take it that it extends the Object class:
> >
> > "All classes that don't declare an explicit base class extend the
> > built-in Object class."
> > http://livedocs.macromedia.com/flex/2/langref/Object.html
> > <http://livedocs.macromedia.com/flex/2/langref/Object.html>
> >
> > Somewhere in my code I'm trying to use a "for each" loop in order to
> > explore the members of B.
> >
> > [code]
> > var obj = Object(instanceOfB);
> >
> > for each(var prop:Object in obj){
> > //do some thing (my code never gets here)
> > }
> > [/code]
> >
> > The problem is that although B (and instanceOfB ) has a number of
> > members the "for each" loop ignores them all and never goes in side
> > the loop.
> > (I used the casting in order to demonstrate that I'm actually using an
> > inheritor of the class Object)
> >
> > What am I doing wrong here?
> >
>