I have the following panel component called AdvancedPanel with controlBarContent:
<!-- AdvancedPanel.mxml -->
<s:Panel>
<s:states>
<s:State name="normal" />
<s:State name="edit" />
</s:states>
<s:controlBarContent>
<s:Button
includeIn="edit"
label="Show in edit"
/>
<s:Button
label="Go to edit"
click="{currentState='edit'}"
/>
</s:controlBarContent>
</s:Panel>
I created a second panel, called CustomAdvancedPanel based on the AdvancedPanel since I don't want to redeclare the controlBarContent
<!-- CustomAdvancedPanel.mxml -->
<local:AdvancedPanel>
<s:Button includeIn="edit" label="Extra edit button" />
</local:AdvancedPanel>
This doesn't work, because the 'edit' state in CustomAdvancedPanel isn't declared according to the compiler. I have to redeclare the edit state in CustomAdvancedPanel.mxml as follows:
<!-- CustomAdvancedPanel.mxml with edit state redeclared -->
<local:AdvancedPanel>
<local:states>
<s:State name="normal" />
<s:State name="edit" />
</local:states>
<s:Button includeIn="edit" label="Extra edit button" />
</local:AdvancedPanel>
Using the CustomAdvancedPanel inside an application component shows an empty panel with the "Go to edit" button. But when I click it, the "Extra edit button" becomes visible, but the "Show in edit" button inside the controlBar doesn't.
When the CustomAdvancedPanel is empty, without redeclared states and "Extra edit button" the panel works just fine.
I think it is because the State object declared in AdvancedPanel isn't the same as CustomAdvancedPanel, so the state is different, even if they have the same name. However. I can't use the states of AdvancedPanel inside CustomAdvancedPanel without (re)declare them in mxml.
Is there any way to achieve this kind of state-reuse? Or is there a better way to obtain the same result?