PDA

View Full Version : Add Child to Custom Component from Main App


dcmike27
10-03-2008, 06:26 PM
I'm trying to write a function in my main app that can add a child (a custom component) to a custom component. The main app is just a viewStack, composed of custom components in vBoxes.

I can get the component to add a child to itself, like this:

var myChild:myCustomChild = new myCustomChild();
this.childHolder.addChild(myChild);

In the sample above, "childHolder" is the id of the vBox inside the component.

But say the component in question is myParent.mxml. What's the syntax for adding the child to it from the main app?

Any hints would be greatly appreciated. Thanks.

rawmantick
10-04-2008, 05:29 AM
Set id for instance of your myParent.mxml instance inside main app. And call addChild() on it referencing by id.

Is that what you need ?

dcmike27
10-11-2008, 10:17 PM
Thanks...that was a huge help!