I think that x and y values are defaulted to 0, 0; which would put your text in the top left of the canvas. The box may layout the canvas, but will not lay out children of the canvas.

This looks like it might be a createChildren method? I would usually position elements in the updateDisplayList method.

- - wrote:
The text always overlaps the canvas and remains at the top... ??? Am I doing something wrong?
* *

*var* parentCanvas: Canvas = *new* Canvas();

parentCanvas.percentWidth =100;

parentCanvas.percentHeight = 100;

* *

*var* childCanvas: Canvas = *new* Canvas();

childCanvas.percentWidth = 100;

childCanvas.percentHeight = 100;

* *

*var* childText:Text = *new* Text();

childText.percentWidth = 100;

childText.text = *'This is a test'*;

parentCanvas.addChild(childCanvas);

parentCanvas.addChild(childText);

box.addChild(parentCanvas);

box is my mxml component.

Thanks.


------------------------------------------------------------------------
*From:* sunild999999 <sunilbd...@gmail.com>
*To:* flexcoders@yahoogroups.com
*Sent:* Tuesday, February 17, 2009 1:37:28 PM
*Subject:* [flexcoders] Re: DYNAMIC actionscript child layout.

I think you want something like this:

var parentCanvas: Canvas = new Canvas();
parentCanvas. percentWidth =100;
parentCanvas. percentHeight = 100;

var childCanvas: Canvas = new Canvas();
childCanvas. percentWidth = 100;
childCanvas. percentHeight = 100;

var childText:Text = new Text();
childText.percentWi dth = 100;

parentCanvas. addChild( childCanvas) ;
parentCanvas. addChild( childText) ;

Let the childCanvas be 100% of the height of it's parent. The parent container will know to leave enough room for childText. I'm not explaining this very well, but the above code
should do what you're looking for.

--- In flexcod...@yahoogro ups.com <mailto:flexcoders%40yahoogroups.com>, - - <sailorsea21@ ...> wrote:
>
> Hi Sunil, this is what I'm trying to replicate in actionscript:
> <mx:Canvasid= "parentCanvas" width="100%" height="100% "> <mx:Canvasid= "childCanvas" width="{parentCanva s.width}"
height="{parentCanv as.height- childText. height}"/ ></mx:Canvas>
> In MXML this layout is DYNAMIC, meaning if I resize my window, all my components are
also resized...
> > How can I replicate this in actionscript? > > Thank you. > > -David
>
>






--
Jeffry Houser, Technical Entrepreneur
Adobe Community Expert: http://tinyurl.com/684b5h
http://www.twitter.com/reboog711  | Phone: 203-379-0773
--
Easy to use Interface Components for Flex Developers
http://www.flextras.com?c=104
--
http://www.theflexshow.com
http://www.jeffryhouser.com
--
Part of the DotComIt Brain Trust

Reply via email to