I would try something like this…
for ( var i:Number=0;i<result.length;i++){
var
initProps:Object={percentWidth:90};
var
myCanvas:Canvas = createChild(mx.containers.Canvas, '', initProps);
initProps={text:myCanvas.id};
myCanvas.createChild(mx.controls.Label,
'', initProps);
}
I have had better luck using createChild
rather than addChild. I have also encountered problems when trying to set
an id when using createChild, and have had better luck letting flex assign an
id automatically. I have been using Flex 1.5, so I don’t know for
certain whether this would work for you in F2B2, but its worth a try.
-Andy
From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Rottman
Sent: Friday, April 28, 2006 1:18
PM
To: [email protected]
Subject: [flexcoders] Re: Adding a
child to a vbox
I think the issue, is
when I try to add a child to a previously
created child. Here is the test code that I have.
for ( var i:Number=0;i<result.length;i++){
// CREATE CANVAS
//
var
newCanvas:Canvas = new Canvas();
newCanvas.percentWidth = 100;
newCanvas.id = "canvas" + i;
var canvasId =
newCanvas.id;
parentApplication.closing.mainBox.addChild(newCanvas);
var
newLabel:Label = new Label();
newLabel.text = canvasId;
parentApplication.closing.mainBox.canvasId.addChild(newLabel);
}
--- In [email protected], "Jeremy Rottman" <[EMAIL PROTECTED]>
wrote:
>
> I have to use parentApplication.... because I am trying to create this
> grid from another state. So I have to work on the parent level.
>
> I have never used getChildByName, would I use it like this.
>
>
parentApplication.closing.mainBox.getChildByName(newGird:string).addChild(newGridRow);
>
>
> --- In [email protected], "Matt Chotin"
<mchotin@> wrote:
> >
> > For one thing I would only do the
> > parentApplication.closing.mainBox.addChild(newGrid) and then for
every
> > other addChild just use the local variable.
> >
> > newGrid.addChild(newGridRow);
> > newGridRow.addChild(newGridItem);
> >
> > It will make things easier to follow, plus I'm not sure
mainBox.newGrid
> > will work unless it has an explicit property called newGrid,
otherwise
> > you have to do getChildByName or something like that.
> >
> > Matt
> >
> > -----Original Message-----
> > From: [email protected]
[mailto:[EMAIL PROTECTED] On
> > Behalf Of Jeremy Rottman
> > Sent: Wednesday, April 26, 2006 8:50 AM
> > To: [email protected]
> > Subject: [flexcoders] Adding a child to a vbox
> >
> > I am still working on this. I need to dynamically create a grid with
a
> > single row, and two items. Then I need to create labels, and text
input
> > inside the grid. However, I cant get to that point yet, I am
still
> > unable to the complete grid w/ a test label in side the grid. I am
> > working with in F2B2.
> >
> > Here is my code.
> >
>
>
for ( var i:Number=0;i<result.length;i++){
>
>
// CREATE GRID //
>
>
var newGrid:Grid = new Grid();
>
>
newGrid.id = 'grid' + i;
>
>
newGrid.percentWidth = 90;
> >
> > parentApplication.closing.mainBox.addChild(newGrid);
>
>
// CREATE GRID ROW //
>
>
var newGridRow:GridRow = new GridRow();
>
>
newGridRow.id = 'gridRow' + i;
>
>
> > parentApplication.closing.mainBox.newGrid.addChild(newGridRow);
> >
>
>
if (result[i].TRANSSIDE is 'buyer'){
>
>
// CREATE GRID ITEM //
>
>
var newGridItem:GridItem = new
GridItem();
>
>
newGridItem.id = 'listGridItem' + i;
>
>
newGridItem.width = 445;
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.addChild(newGridIte
> > \
> > m);
>
>
// CREATE CANVAS //
>
>
var newCanvas:Canvas = new Canvas();
>
>
newCanvas.id = 'canvas' + i;
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.newGridItem.addChil
> > \
> > d(newCanvas);
>
>
// CREATE LABEL //
>
>
var newLabel:Label = new Label();
>
>
newLabel.text = "TEST";
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.newGridItem.newCanv
> > \
> > as.addChild(newLabel);
> >
>
>
}
>
>
else if (result[i].TRANSSIDE is 'seller'){
>
>
// CREATE GRID ITEM //
>
>
var newGridItem:GridItem = new
GridItem();
>
>
newGridItem.id = 'saleGridItem' + i;
>
>
newGridItem.width = 529;
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.addChild(newGridIte
> > \
> > m);
>
>
// CREATE CANVAS //
>
>
var newCanvas:Canvas = new Canvas();
>
>
newCanvas.id = 'canvas' + i;
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.newGridItem.addChil
> > \
> > d(newCanvas);
>
>
// CREATE LABEL //
>
>
var newLabel:Label = new Label();
>
>
newLabel.text = "TEST";
>
>
> >
parentApplication.closing.mainBox.newGrid.newGridRow.newGridItem.newCanv
> > \
> > as.addChild(newLabel);
> >
>
>
}
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS