> 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?

The reason that components do not create their children immediately when
they are created is so that you can set properties after calling 'new'
and have these properties affect which children get created. For
example,
 
var clock:Clock = new Clock();
clock.mode = "analog";
addChild(clock);
 
The Clock would need completely different children if the mode were
"digital" instead of "analog". By delaying the creation of the children
until addChild(), the framework makes it possible to optimize which
children are created.
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of bhaq1972
Sent: Monday, April 30, 2007 4:57 AM
To: [email protected]
Subject: [flexcoders] creating instances, addChild question



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
<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>



 

Reply via email to