Marthin
Marthin

Reputation: 6543

Add child to parent component that is not visible in flex

I have a mxml file that extends a parent class. The parent has a component that is hidden initially and only shown once a button is pressed. I would like to add a new child component to this hidden component from my extended mxml. Is there a way to access the super component and add the child once the buton is pressed? Maybe listen to an event?

Right now i have a solution that solves the problem by loading the hidden components but it´s not a nice solution.

super.advancedOptionsSearchBox.getChildren();
super.advancedOptionsSearchBox.addChildAt(getEANContainer(), 1);

If i do not call the getChildren I get a index out of bounds exception on the call to addChildAt method since the array of children is empty in the hidden component.

Upvotes: 0

Views: 193

Answers (1)

Pete TNT
Pete TNT

Reputation: 8403

Couldn't you just set property

creationPolicy="all"

to your component? That way it's created even if it's initially not visible.

Upvotes: 1

Related Questions