I'm writing a board game in Flex that supports between 2 and
5 players. Each player gets his/her own mini-board to play on, so
I've written a MXML component called PlayerBoard, which is a Canvas
component. In the first iteration of my MXML application, I had 5
of these PlayerBoard components laid out inside a VBox. They
appeared exactly as expected.
However, if there are less than 5 players, I don't want the
unused boards to show up. Consequently, I've set my VBox
creationPolicy to "none", and then I use
createComponentFromDescriptor() to instantiate only the boards that
are needed for the game. This is working in all regards except one:
The created boards are not being positioned in the VBox correctly!
What appears to be happening is the proper boards are being
created, but they are all stacked on top of each other in the upper
left hand corner where my VBox is anchored.
Now, I can unstack them simply by giving them x/y coordinates
so that when they are created, they will appear in the correct
(fixed) positions, but that seems to defeat the purpose of using a
VBox! Is there any way to get the VBox container to properly lay
out my manually instantiated MXML components? Or is the VBox only
sized upon creation with no way to change it after it's been
created? I have tried calling validateNow() (based on some stuff I
read in the Container documentation) but to no avail.
Any and all help appreciated. Many thanks. This Flex stuff is