Hi

 You need to type cast the object/component to  DisplayObject

 

Just keep in mind: any container you want to add any object just typecast to
DisplayObject();

 

i.e  

 Here mainGrpHolder is some kind of holder container i.e canvas, VBox, HBox

 

var gObj: ColumnChart = new ColumnChart ();

mainGrpHolder.addChildAt(DisplayObject(gObj),i); or
mainGrpHolder.addChild(DisplayObject(gObj));

For using any properties for component/object added use: reverse the
type-cast .

gObj = ColumnChart (mainGrpHolder.getChildAt(i));

trace(gObj.PropertName);

trace(gObj.methodName());

 

This works very fine,I used it.

 

Thanks & Regards

Jolly

************************************************************************
Life Fitness - A Division of Brunswick Corporation
#09-02,  The Signature, 
Changi Business Park Central 2, Singapore-486066
(Cell) 65 -96216408 (Tel) 65-62606409 (Fax) 65-62605150
http://www.lifefitness.com <http://www.lifefitness.com/>  |
http://www.brunswick.com <http://www.brunswick.com/>  
************************************************************************

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Manish Jethani
Sent: Saturday, April 28, 2007 10:20 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] addChild problems

 

On 4/26/07, Jason C Reynolds <[EMAIL PROTECTED]
<mailto:jreynolds%40thewritesource.com> > wrote:

> MainApp
> contentHolder = new Canvas();
> this.addChild(contentHolder);
> contentScreen = new SampleScreen();
> contentHolder.addChild(contentScreen); // HERE is what I want to work,
contentScreen extends UIComponent - so in my mind it should work (show up on
screen).
>
> SampleScreen
> question = new Text();
> question.text = "some text";
> this.addChild(question); // HERE is the other change from the working
version.

So if you add the Text object directly to the Canvas, it works, but,
if there's a UIComponent in between, it doesn't.

Canvas => UIComponent => Text // doesn't work
Canvas => Text // works

Suggestions:

1) Check question.parent.parent ... is it pointing to the Canvas?
2) Compile with -debug and see if you're getting a runtime error
(and see the stack trace)
3) Are you overriding measure() in your UIComponent? If not, at
least set its width and height explicitly.

 

Reply via email to