I created a custom MXML component, TurboContent, that extends the NavigatorContent class:
<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Metadata>
[DefaultProperty("mxmlContentFactory")]
</Fx:Metadata>
<s:Group id="midWrapper">
<s:Button id="btnAdd" />
</s:Group>
<s:Group id="rightWrapper" >
<s:DataGrid id="dgdSelect" >
<s:columns>
<s:ArrayList>
<s:GridColumn headerText="Yo"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button id="btnRemove" />
<s:Button id="btnClear" />
</s:Group>
</s:NavigatorContent>
I am trying to extend that custom component but when I add display elements to the second extended componet they elements are never seen. For instance: (The first custom component is in the comp package)
<comp:TurboContent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comp="comp.*">
<s:Button id="myButton"/>
</comp:TurboContent>
In this case, the ‘myButton’ component never shows up, but all the elements of the base component do (3 buttons and a datagrid).
From what I can tell, the pattern of defining a component directly in MXML (as you referenced was done in the FIAW series) disallows the ability to then visually insert children in the container’s display list. One of the problems is that the
mxmlContent(which normally a skin would control) is statically defined in the component and it doesn’t seem like one can usecontentGroupinside the MXML component directly.For better control, and what I consider a more strict implementation of the MVC pattern (which Flex 4, as a framework, implements), try separating your visual layout out into an MXML skin, and defining the component in AS3.
From what little I see of your component, I can’t really make a judgment as to what properties of the component you want to expose to the container that will instantiate it. I’ll at least give an example here of how one can pass info from the component to the skin.
I apologize for the MX components, but I only have Flex 4.1, and I wanted to make sure the program compiled fine. It shouldn’t be too hard for you to swap in the spark versions.
Example Component (TurboContentAS.as)
Example Skin (TurboContentSkin.mxml)
Example Instantiation