views:

610

answers:

4

Hello,

I have a component composed of two parts, let's say two Hbox A and B in a Vbox.

On a specific call I want to:

- Hide B with B.visible = false
- setStyle("borderSkin", FooBorderOn);

The problem is that the border get drawn before the resizing of the parent Vbox happen, so i end up with a border Around the Vbox with B invisible :

.....................
.         A         .
.                   .
.                   .
.                   .
.     BLANK SPACE   .
.....................

I would like the border to et around the next updated size of the vbox. Is there something like "do that afer redraw" ? in flex ?

Thanks a lot

+1  A: 

Take a look at the callLater method. This will postpone a method call until the next frame update.

Chris Thornhill
A: 

It was callLater ... I had it in my memory somewhere

coulix
A: 

Even if you hide the VBox, HBox B is still there. I would shrink the height of the VBox, set the VerticalScrollPolicy to false (so that the scroll bar won't show), or just plain remove the HBox from the VBox (myVBox.removeChild () ).

Aethex
A: 

There are several ways to postpone actions. If you're developing a UI component yourself, take a look at invalidateProperties / commitProperties. This is a mechanism to not get stuck in update loops: you mark a property to be updated (usually by storing it in a temp var and/or adding a xxxChanged Boolean) and call invalidateProperties(). Flex will then call commitProperties() a bit later - accumulating several changes which might affect each other - where you can do your actual change.

callLater would also be an option, though usually it's not as "later" as one would think :) (It's the next screen refresh, which could happen quite soon, even before other queued actions)

However in your case, from your description, I think you just missed the "includeInLayout" property. Containers will decide to display (visible) or make room for (includeInLayout) for objects based on those two, separate properties. See also Preventing layout of hidden controls.

Zefiro