<mx:MenuBar> Gotcha.
After almost an hour and some hair pulling I finally figured this one out.
| SCENARIO: | I want to drive a <mx:MenuBar> from an external XML file. |
Easy enough!
Here is my XML:
<root>
<menuitem label="Main Menu 1">
<menuitem label="Menu 1 Command 1"/>
<menuitem label="Menu 1 Command 2"/>
</menuitem>
<menuitem label="Main Menu 2">
<menuitem label="Menu 2 Command 1"/>
</menuitem>
</root>
<menuitem label="Main Menu 1">
<menuitem label="Menu 1 Command 1"/>
<menuitem label="Menu 1 Command 2"/>
</menuitem>
<menuitem label="Main Menu 2">
<menuitem label="Menu 2 Command 1"/>
</menuitem>
</root>
My MXML:
<mx:MenuBar id="mainMenu" width="100%" labelField="@label">
<mx:XML format="e4x" source="assets/mainmenu.xml"/>
</mx:MenuBar>
<mx:XML format="e4x" source="assets/mainmenu.xml"/>
</mx:MenuBar>
No compile errors, but when I run the application i get this:

The answer is so simple, but it eluded me. The <mx:MenuBar> has a showRoot attributes that is true by default.
New code:
<mx:MenuBar id="mainMenu" width="100%" labelField="@label" showRoot="false">
<mx:XML format="e4x" source="assets/mainmenu.xml"/>
</mx:MenuBar>
<mx:XML format="e4x" source="assets/mainmenu.xml"/>
</mx:MenuBar>
Fixed:

Sometimes Flex is too easy!
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
[Add Comment]
Thanks for posting this, I was having the same problem.
# Posted By John
| 7/27/07 8:11 PM
[Add Comment]


