title: Flex/AS3/XML: how to dynamically change XMLList used for Flex submenu?
body: <p>Using actionscript 3, can someone give an example how I can dynamically change the submenu items below? </p>
  
  <pre><code>&lt;fx:Declarations&gt;
  &lt;fx:XMLList id="menuData" xmlns=""&gt;
      &lt;menuitem label="Column A"&gt;
              &lt;menuitem label="Item A.1"/&gt;
              &lt;menuitem label="Item A.2"/&gt;
      &lt;/menuitem&gt;
      &lt;menuitem label="Column B"&gt;
              &lt;menuitem id="ItemB1" label="B.1"/&gt;
              &lt;menuitem type="separator"/&gt;
              &lt;menuitem label="Item B.2" type="check"/&gt;
              &lt;menuitem label="Item B.3" type="check"/&gt;
              &lt;menuitem id="myId" label="Item B.4"&gt;
                  &lt;menuitem label="SubItem B.4.1"/&gt;
                  &lt;menuitem label="SubItem B.4.2"/&gt;
              &lt;/menuitem&gt;
      &lt;/menuitem&gt;
          ...
  &lt;/fx:XMLList&gt;
  &lt;fx:Declarations&gt;
  ...
  &lt;mx:MenuBar dataProvider="{menuData}" .../&gt;
  </code></pre>
  
  <p>For example, suppose we want to replace submenu items B.4.1 and B.4.2 with:</p>
  
  <pre><code>&lt;menuitem label="SubItem abc"/&gt;
  &lt;menuitem label="SubItem def"/&gt;
  &lt;menuitem label="SubItem ghi"/&gt;
  </code></pre>