Components are resized by their parents, so even if an object is
updated/measured it will not be resized until the parent is updated. I'm not
sure what the timing of the parent updating is relative to adding a child.
After calling 'addChild()' and before calling 'layoutWindowsHorizontally()'
try explicitly calling 'child.validateSize(true)' and '
child.parent.validateDisplayList()'

- Dan Freiman

On 11/2/07, Daniel <[EMAIL PROTECTED]> wrote:
>
>   Hey guys,
>
> I'm working in an application where I need to layout a bunch of panels
> called 'windows'. The container of this panels is another panel called
> 'panelContainer'. I need to layout the windows horizontally,
> vertically or absolute, depending of the button pressed byt the user.
> Of course I could use the panelContainer.layout property, but I need
> to set a move effect for each window, so I analyse the children of the
> panelContainer and set the percentWidth and percentHeight and add a
> listener for an updateComplete event for each Window. In the
> updateCompleteHandler I move the Windows to its new X position with
> the move effect, and calculate the X of the next window.
>
> My problem is when I add a new Window to panelContainer. The default
> size of a new Window is 400x400. I add the Window to panelContaner
> throught panelContainer.addChild(newWindow) and then I call to the
> layoutWindows method. The new window should be treated like any other
> window, right? This doesn't happen... In the updateCompleteHandler,
> the recently added window still has the default size (400x400) instead
> of the assigned percentWidth and percentHeight...
>
> Does anyone know why this happen?
>
> I'll post the code for the layoutWindowsHorizontally and the
> updateComplete handler...
>
> private function layoutWindowsHorizontally ():void
> {
> posX = 0; // variable that sets the X position of each Window.
> for (var i:int = 0; i < panelContainer.numChildren; i++)
> {
> if (panelContainer.getChildAt(i) is WindowPanel) // if a child of
> the panelContainer is a WindowPanel
> {
> var p:WindowPanel = panelContainer.getChildAt(i) as WindowPanel;
> // it sets its size
> p.percentHeight = 100;
> p.percentWidth = 100 / panelContainer.numChildren;
> p.addEventListener("updateComplete",updateCompleteInHorizontal);
> // and adds the listener to updateComplete
> p.addEventListener(ResizeEvent.RESIZE, resizePanel); //adds a
> resize effect to the window
>
> }
> }
> panelContainer.validateNow();
> }
>
> private function updateCompleteInHorizontal(event:Event):void //
> called when the new size of the Windows are set.
> {
> var p:WindowPanel = event.currentTarget as WindowPanel;
> moveEffect(p, posX, 0); // moves the panel to its position
> posX = posX + p.width; // sets the X position of the next Window.
> p.removeEventListener("updateComplete",updateCompleteInHorizontal);
> // removes the listeners.
> p.removeEventListener(ResizeEvent.RESIZE, resizePanel);
> }
>
> Any help is appreciated... This is driving me crazy...
>
>  
>

Reply via email to