« Flex debug not working after updating to a new version of flash player
» Sony Ericsson web site

ActionScript, MXML

To disable an item of a MenuBar

11.10.07 | Comment?

Having the code bellow:

 <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" 
         layout="absolute">
     <mx:script>
     <!--[CDATA[
 
     public static const menubarXML:XMLList     =
     <root>
     <menuitem label="main1" data="1">
         <menuitem label="sub1" data="1_1"/>
         <menuitem label="sub2" data="1_2"/>
         <menuitem label="sub3" data="1_3"/>
         <menuitem type="separator"/>
         <menuitem label="sub4" data="1_4" />
     </menuitem>
     <menuitem label="main2" data="2">
         <menuitem label="sub1" data="2_1"/>
         <menuitem label="sub2" data="2_2"/>
         <menuitem type="separator"/>
         <menuitem label="sub3" data="2_3"/>
     </menuitem>
     <menuitem label="main3" data="3">
         <menuitem label="sub1" data="3_1">
             <menuitem label="subsub1" data="3_1_1"/>
             <menuitem label="subsub2" data="3_1_2"/>
             <menuitem label="subsub3" data="3_1_3"/>
             <menuitem label="subsub4" data="3_1_4"/>
             <menuitem label="subsub5" data="3_1_5" />
         </menuitem>
         <menuitem label="sub1" data="3_2"/>
         <menuitem label="sub1" data="3_3"/>
         <menuitem label="sub1" data="3_4"/>
     </menuitem>
     </root>;
 
     public function getData(item:Object):String {
         return XML(item).@label;
     }
 
    ]]-->
    </mx:script>
 
    <mx:menubar dataprovider="{menubarXML}"
              labelfunction="getData" x="10" y="10"
              width="652"></mx:menubar>
</mx:application>

To disable an item just add “enable” attribute with “false” to the XML node for the item.

<menuitem label="sub1" data="1_1" enabled="false"></menuitem>

Popularity: 23%

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • DZone
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , , ,

This post was written by Andrei Ionescu

Views: 1154

related

popular

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« Flex debug not working after updating to a new version of flash player
» Sony Ericsson web site