5 Replies Latest reply on Feb 8, 2007 7:42 AM by Pigg_Man

    How to delete a menuItem from a menuBar Component?

    Pigg_Man
      I have a menuBar component and need to remove an item from it when a user performs some action. Here is my MenuBar struct:
      <node id="1">
      <node id="2">
      <node id="3"/>
      </node>
      </node>
      I want to remove node 3.. I can get the node but can't delete it... I used
      var menu:XML = XML (MenuDP.getItemAt(0));
      var menuItem:XML = menu.children()[0];
      var node3:XML = XML(menuItem.children()[0]);

      If I do a trace on node 3 then it's the right node... So I would think that I could do something like this to remove it.. But it doesn't work:
      var menuItemChildren:XMLListCollection = new XMLListCollection(menuItem.children());
      menuItemChildren.removeItemAt(0);

      but that give me a ... cannot remove something from null or something like that..

      Any Ideas?