How to define custom “content groups” in a Flex 4 custom component?

A component of a spark panel, for example, can be written as follows

<Panel title="Skinny"> <child components ... /> <controlBarGroup> <child control bar components ... /> </controlBarGroup> </Panel> 

And his skin file will handle the layout of contentGroup, controlBarGroup and titleDisplay. Note, however, that the contentGroup is not displayed in the code above and that controlBarGroup accepts mxml child components.

Now say that I want to create a custom component that defines various required and optional design elements, such as 'headerGroup', 'navigationGroup' and 'accountPreferencesGroup'. I would like to write this custom component like this

 <MyComp> <headerGroup> <child components .../> </headerGroup> <navigationGroup> <child components .../> </navigationGroup> <accountPreferencesGroup> <child components .../> </accountPreferencesGroup> </MyComp> 

The motivation here is that now I can create a couple of different skin files to change the look and layout of these subgroups. When reading the source of the spark panel, there are some calls inside the mx_internal namespace, such as getMXMLContent (), which is a method of the spark group component, but which I do not have access to.

Does the description above make sense? How do I create custom “content groups” in my custom Flex4 component that can use child components of nested mxml? Should I approach this differently?

+6
flex custom-component flex4
source share
2 answers

I recently looked at this blog post. I think this gives a pretty good explanation of what you are talking about.

http://saturnboy.com/2010/07/multiple-content-area-containers/

+6
source share

So ... after working on something else ... I found that it can be used with mx_internal namespace by adding the following

import mx.core.mx_internal; use namespace mx_internal;

Adobe uses this namespace to indicate methods and properties that may change in the future, so they use this namespace to hide things.

If you execute the code in Panel.as, you can get this working and define your own content areas.

0
source share

All Articles