Thanks Mike this is great advice and knowledge. > What problems are you facing without being able to access box children after > the new call and before the addChild() call?
I'm modifying a printing example from the livedocs which uses a print template component..... I was making a more generic template. I wasn't too sure why the template instance was being added to the application and then only to be removed after the printJob completes...except, that the box children were being instantiated as well. i was thinking an mxml component would generate an AS class where the children would also be instantiated in the constructor. a little knowledge can be dangerous. regards bod --- In flexcoders@yahoogroups.com, "Michael Schmalle" <[EMAIL PROTECTED]> wrote: > > Hi, > > Basically, you have to change the way you think about instantiation. > > Calling the new operator creates memory allocation, accessibility, enables > and adds some listeners. This is like preinitialization. > > What you now have to think is, addChild() is now the constructor of any > UIComponent. > > If you follow this flow you are fine; > > Call you constructor. > Set any initialization properties. > Set dimensions. > Add listeners. > > Now, that you instance is ready to go, when you are ready to addChild() you > will then have access to your children. > > When you call addChild(), createChildren is called. You will always have > access to the children, unless some a re deferred. > > Just get over the fact that you call addChild() and all is well. > > What problems are you facing without being able to access box children after > the new call and before the addChild() call? > > Peace, Mike > > > On 4/30/07, bhaq1972 <[EMAIL PROTECTED]> wrote: > > > > Thanks Mike > > > > If i want to create a new instance of an mxml component, how can i > > ensure its children get created as well. > > > > --- In flexcoders@yahoogroups.com <flexcoders% 40yahoogroups.com>, "Michael > > Schmalle" > > <teoti.graphix@> wrote: > > > > > > the flow, > > > > > > new VBox() > > > > > > "I was wrong about the constructor calling initialize()" :) > > > > > > addChild() > > > - addChildAt() > > > - childAdded() > > > - initialize() > > > - createChildren() > > > > > > Peace, Mike > > > > > > On 4/30/07, Michael Schmalle <teoti.graphix@> wrote: > > > > > > > > Ha it's the morning and just waking up... > > > > > > > > The real anwer is, > > > > > > > > addChild() will eventually call createChildren(). Since you have > > not > > > > called addChild() on your VBox mxml component, createChildren () > > has not been > > > > called. > > > > > > > > createChildren() does not get called from a constructor call, > > just > > > > initialize(). > > > > > > > > Peace, Mike > > > > > > > > On 4/30/07, Michael Schmalle < teoti.graphix@> wrote: > > > > > > > > > > Hi, > > > > > > > > > > Don't quote me but, > > > > > > > > > > I think it has to do that you do not have a parent on your > > main VBox > > > > > instance. > > > > > > > > > > I don't think createComponentsFromDescriptors() is called until > > > > > parentChanged() or something is called (IE the parent VBox > > actually has a > > > > > parent). > > > > > > > > > > This shouldn't be a problem, the timing of invalidation gives > > you plenty > > > > > of time to initialize your children when they are finally > > added to the > > > > > display list of the stage. > > > > > > > > > > Peace, Mike > > > > > > > > > > On 4/30/07, bhaq1972 <mbhaque@> wrote: > > > > > > > > > > > > This question is very similar to a question someone else > > is asking > > > > > > (may even be the same thing????) > > > > > > > > > > > > I've got a component called MyPrintView.mxml > > > > > > > > > > > > <mx:VBox> > > > > > > <mx:Label id="contact"/> > > > > > > <mx:PrintDataGrid id="printDG"/> > > > > > > </mx:VBox> > > > > > > > > > > > > when i create an instance of MyPrintView, its children are > > not > > > > > > created. why is that? > > > > > > > > > > > > if you addChild() to the Application....they are created. > > why is > > > > > > that? > > > > > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > > > > > initialize="startUP()"> > > > > > > > > > > > > <mx:Script> > > > > > > <![CDATA[ > > > > > > private function startUP():void > > > > > > { > > > > > > var printView:MyPrintView = new MyPrintView(); > > > > > > trace(printView); > > > > > > trace(printView.printDG, printView.contact); //both null > > > > > > addChild(printView); > > > > > > trace(printView.printDG, printView.contact); //both not null > > > > > > > > > > > > } > > > > > > ]]> > > > > > > </mx:Script> > > > > > > </mx:Application> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Teoti Graphix > > > > > http://www.teotigraphix.com > > > > > > > > > > Blog - Flex2Components > > > > > http://www.flex2components.com > > > > > > > > > > You can find more by solving the problem then by 'asking the > > question'. > > > > > > > > > > > > > > > > > > > > -- > > > > Teoti Graphix > > > > http://www.teotigraphix.com > > > > > > > > Blog - Flex2Components > > > > http://www.flex2components.com > > > > > > > > You can find more by solving the problem then by 'asking the > > question'. > > > > > > > > > > > > > > > > -- > > > Teoti Graphix > > > http://www.teotigraphix.com > > > > > > Blog - Flex2Components > > > http://www.flex2components.com > > > > > > You can find more by solving the problem then by 'asking the > > question'. > > > > > > > > > > > > > -- > Teoti Graphix > http://www.teotigraphix.com > > Blog - Flex2Components > http://www.flex2components.com > > You can find more by solving the problem then by 'asking the question'. >