Wednesday, July 16, 2008

Copy Children From One Flex Container to Another

Okay, this shouldn't be so difficult but I'm having a helluva time with it. I have two canvases. All I want to have happen is when I add a child to canvas A I want it to also be added to canvas B at the same time. Sounds easy right, but for some reason it's only showing up in the second canvas, not the first. It's driving me crazy. Any ideas out there?

var imageContainer:WallItem = new WallItem();

When I do this the item only shows up in the "navCanvas" but if I take out the second addChild it shows up fine in "dropArea." What am I missing?


Logan said...

A single instance of a component can only have a single parent and live in a single container. You are adding the same instance of the component to both containers, so when it is added to the second container, it is removed from the first.

You need to instantiate 2 different instances of the component and configure them the same (bind them to the same data source, or bind them to each other) or wire up their events so they'll both be handled the same, depending on what you're trying to do.

tt said...

thanks logan. that was very helpful, i got it working now.