Hi everybody!

I'm having trouble in changing my MenuBar menu items labels in real
time, even when I use e4x in order to access the labels and modifiy
them.
The strangest thing of all is that I'm able to change submenu items'
labels, but not the top menu items.

Let me explain myself by showinf you some code:

Here is the declaration of my menu, MXML-style:
<mx:MenuBar width="100%" labelField="@label" id="MyMenuBar"
itemClick="menuProcessor(event)">
         <mx:XMLList>
             <menuitem label = "File">
                 <submenuitem label="New"/>
                 <submenuitem label="Open"/>
                 <submenuitem label="Change Label"/>
             </menuitem>
         </mx:XMLList>
     </mx:MenuBar>

and here is my menu event handler function, which is located in the same
MXML file:

public function menuProcessor(event:MenuEvent):void
  {
     switch (event.label){
         case "Change Label"
               mymenubar.dataprovider[...@label = "'file' label
changed!";  // this won't work
               event.it...@label="'change label' label also changed,
yeah!"; // this will work
          break;
      }
  }

Then, as I told you, the menu displays as the following:

File
----> 'change label' also changed!

when it should have displayed as the following:

'file' label changed!
----> 'change label' also changed!

Why does the submenuitem change and the top menu one dosen't??



Now, here comes a funny thing... If I change the previous code by adding
a couple of lines:

public function menuProcessor(event:MenuEvent):void
  {
     switch (event.label){
         case "Change Label"
               mymenubar.dataprovider[...@label = "'file' label
changed!";
               event.it...@label="'change label' label also changed,
yeah!";
               MyMenuBar.enabled = false;
               MyMenuBar.enabled = true;
          break;
      }
  }

...then everything works fine!



Can anybody throw some light on this? I'm really lost, I can't begin to
understand what's going on here!
I guess that whenever I change the "enabled" property of a MenuBar it
somehow updates the labels in the top menu items, but how can I force
the update withouth having to change the update property??

Thank you all!

Reply via email to