I feel as though I'm overlooking something simple here.
Rather than using states, I'm controlling my layout through script
functions. For example, button1 creates component1 and places it in
its respective container. Component1 is therefore created within
the script block, then added to the predefined container (via
Now that I've completed my layout functionality I want to
start building the actual components with which the user will
interact. For the sake of modularity I want these to be custom
components, and I believe they need to be added programmatically. I
swapped out the existing placeholder code for the "orderForm"
//create the order form
var orderForm:HBox = new HBox();
orderForm.width = 600;
orderForm.height = 60;
var label:Label = new Label();
label.text = "Order Form";
//add it to its designated container
with some pretty shady code that I made up. It was something
like "var orderForm : OrderForm = new OrderForm();". Now I know
that's incorrect because I haven't created a new object and
certainly haven't defined a constructor for it, but I'm wondering
how this can be done inside a script function.
Additionally, if I create the component with MXML and hide
it, it doesn't have the intended behavior. It still takes up space
as a hidden component, and upon becoming visible, it doesn't reside
in the proper area (despite my attempts to place it dynamically).
That line is ok:
var orderForm : OrderForm = new OrderForm();".
It does create a new Orderform object that you can ad to your
What is not working?
On the second problem, to toggle the display of a component
like you are trying, you pretty much need to use a Canvas
container. You can fiddle with the includeInLayout property but
normal layout containers have their own ideas.
What do you mean by "doesn't reside in the proper area "?