the blog
Back to -Blog

Adobe Flex 4 Children and Elements

How to use MX and Spark Containers
by Huw Collingbourne
Thursday 1 July 2010.

I’ve written an article for this month’s Flash & Flex Developers’ Magazine (July 2010) which may be of interest if you are migrating from Flex 3 to Flex 4 or using a mix of MX and Spark components in Flex 4 applications.

The problem is that Flex 4 redefines the parent/child relationships of components. In Flex 3, when you put an MX component inside an MX Container, the Container was the parent of the component and the component was a child of the Container.

In Flex 4, things don’t work that way. A Spark Container may have several levels of objects intervening between it and any controls which it contains. Moreover, its contents are not (strictly speaking) its children but its elements.

To manipulate the components inside Spark containers you need to use a different set of methods than when manipulating components inside MX containers. Things get even more complicated if your applications contain a mix of both Spark and MX controls. If you use the wrong methods or try to access the incorrect parent, your program may not work as intended. This is a problem we’ve had to grapple with ourselves in order to allow the Amethyst Designer (our drag-and-drop Flex design environment) to work with both MX and Spark controls. In this article (the first of two) I explain some simple techniques that can help you to avoid some knotty problems.

Flash & Flex Developers’ Magazine is a free PDF magazine which can be downloaded here: If you are a serious Flash or Flex developer you should bookmark the site and download every issue as it is an invaluable source of information on a broad variety of development topics.

Bookmark and Share   Keywords:  Flex
© SapphireSteel Software 2014