Question

I am new to Flex. Recently, I am learning about 'state' concept in Flex.

When state is changed, we can define the new properties for the new state overidding the properties of the base state.

But, I had a doubt.
What is the difference between using setProperty() and removeChild() in Flex ?

Take the following case.
Suppose there are 2 Vbox inside the application container. When the state is changed by some event, I need only 1 VBox in the appln container.

(a) Should I set setProperty for that particular VBox of width and height to 0 ? or
(b) Should I remove the VBox from the new state by using removeChild() property ?

Was it helpful?

Solution

They are different. SetProperty means changing some properties of the instance, you can set any property that you can access in the context. In case you need to re-use the VBox in future (i think this is your case), you should utilize this function. Normally, don't set width and height to 0 (some components has minimumWidth and minimumHeight that can break your logic). Instead, set its visible to false and includeInLayout to false too.

You only use removeChild when you no longer need that VBox. Otherwise, when you need to addChild it into your layout, you have to rearrange the order of the component's children.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top