I have a requirement for my current project (the Flex application that will run in Flash Player) to display an arbitrary subset of the components in the form, hiding all other components based on certain aspects of the state of the application. There are about a dozen different text fields and drop-down lists, but some become irrelevant based on previously entered user data, and we do not want to display them when we get into this particular form. Each time this form is displayed, I may need to show any of the many permutations of these components.
I am trying to decide how best to approach this problem. Should I create a canvas (or another container) with all the necessary controls on it, and then just set visible = false on the ones I don't need? Then there is the problem that the layout looks decent. I don't want there to be spaces where hidden controls would be.
Another option that I was thinking about is simply a mechanism that could dynamically create an instance of a TextInput or CheckBox component and then call container.addChild (control) to create the components and not worry about the problem.
This seems like a problem that has an idiomatic solution in flex, but I don't know what it is. None of these ideas seem great, so I wonder if anyone else has a better idea.
source
share