One of the cool features of Flex is the ability to make a dynamic interface that is more reminiscent of desktop applications than most web-based applications. One of the tasks it can do out of the box is let you control the visibility of entire parts of your application. This is helpful when dealing with an application that may consist of different sections, not all of which should be visible at one time. With some of the standard Flex controls, you can partition your application into different views, even allowing people to customize the way they want to see a certain section.

Controlling Visibility

Every visual component in Flex has the ability to turn its visibility off and on. You control this with the visible property, which is true by default. This applies to all visual controls that Flex has, but it also applies to containers. As you have learned, containers are great tools not just for helping to align and lay out your application but also for structuring the different parts of your application. Because containers are visual components, they inherit such properties as visibility. This means you can set an entire container’s visibility, and that property will propagate to the container’s children.

Setting visible to false makes a component invisible, but it continues to take up its allotted space. For example, you may have a row of three buttons aligned horizontally inside an HBox. Turning the middle button’s visibility off still allows ...

Get Learning Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.