It may be because of deferred instantiation the component doesn't actually have children yet.
On Fri, Aug 21, 2009 at 10:29 PM, alexeoscar <[email protected]> wrote: > Suppose you have a MyView.mxml file, which is basically a Panel with > several children (Form, FormItems, Buttons...). > > Is it possible to iterate over the MyView and get all the information about > its children (types, id ...) before it is displayed. > > In my Main.mxml if I have this function > > public function iterateOverChildren(comp:Container):void { > // Get the number of descriptors. > trace("Running iterateOverChildren for " + comp.id); > if (comp != null) > { > var n:int = comp.childDescriptors.length; > for (var i:int = 0; i < n; i++) { > var c:ComponentDescriptor = comp.childDescriptors[i]; > var d:Object = c.properties; > > // Log ids and types of objects in the Array. > trace(c.id + " is of type " + c.type); > > // Log the properties added in the MXML tag of the object. > for (var p:String in d) { > trace("Property: " + p + " : " + d[p]); > } > } > } > } > > > Why does this call not work ? > > var myV = MyView(); > iterateOverChildren(myV); > > It only works if I add a statement like > addChild(myV); > before the iterateOverChildren call. (But that's not what I want, I want to > iterate the descriptions without adding it to display). > > -alex > > > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > >

