Macromedia flex 2 Manual

Page of 254
Implementing the component
169
            // of the VBox.
            var yOfComp:Number = height-vm.bottom;
            
            // Temp variable for a container child.
            var obj:UIComponent;
                
            for (var i:int = 0; i < numChildren; i++)
            {
                // Get the first container child.
                obj = UIComponent(getChildAt(i));
            
                // Determine the y coordinate of the child.
                yOfComp = yOfComp - obj.height;
                
                // Set the x and y coordinate of the child.
                // Note that you do not change the x coordinate.
                obj.move(obj.x, yOfComp);
                
                // Save the y coordinate of the child,  
                // plus the vertical gap between children. 
                // This is used to calculate the coordinate 
                // of the next child. 
                yOfComp = yOfComp - gap;
            }
        }
    }
}
In this example, you use the 
UIComponent.move()
 method to set the position of each child in 
the container. You can also use the 
UIComponent.x
 and 
UIComponent.y
 properties to set 
these coordinates. The difference is that the 
move()
 method changes the location of the 
component and then dispatches a 
move
 event when you call the method immediately; setting 
the 
x
 and 
y
 properties changes the location of the component and dispatches the event on the 
next screen update.