Flex How to delay setStyle until next update?

I have a component with two parts, say two Hboxes A and B in a Vbox.

For a specific call, I want:

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

      

The problem is that the border is drawn before the parent Vbox is resized, so I end up with a border around the Vbox with B invisible:

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

      

I need a border for et around the next updated vbox size. Is there something like "do to afer redraw"? in flex?

Thank you very much

+1


a source to share


4 answers


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



+2


a source


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



0


a source


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 scrollbar is not shown), or simply remove the HBox from the VBox (myVBox.removeChild ()).

0


a source


There are several ways to postpone action. If you are developing a UI component yourself, take a look at invalidateProperties / commitProperties. It's a mechanism that doesn't get stuck in update loops: you mark the property to be updated (usually by storing it in temp var and / or adding an xxxChanged Boolean) and call invalidateProperties (). Flex will then call commitProperties () a little later - after copying a few changes that might affect each other - where you can make your actual change.

callLater would also be an option, although usually not as "later" as one might think :) (This is the next screen refresh, which could happen pretty soon, even before other events in the queue)

However, in your case, from your description, I think you just missed the includeInLayout property. The containers will decide to display (visible) or free up space (includeInLayout) for objects based on these two separate properties. See also Preventing the layout of hidden controls .

0


a source







All Articles