actionscript 3 - Flex menuitem from menubar disable -
i have small issue related enabling/disabling menuitems in flex.
the question can disable directly menuitem not it's sub-menuitems.
i have following menu structure:
public var menuagroapp:xmllist = <> <menuitem label="admin"> <menuitem label="option 1"/> <menuitem label="option 2"/> <menuitem label="option 3"/> <menuitem label="option 4"/> </menuitem> <menuitem label="prices"> <menuitem label="price 1"/> <menuitem label="price 2"/> <menuitem label="price 3"/> </menuitem> <menuitem label="orders"> <menuitem label="order 1"/> <menuitem label="order 2"/> </menuitem> </>;
with code can disable menu "admin" not option:
menuprincipal.datadescriptor.setenabled( xml(modeloglobal.modelo.menuagroappcollection.source[0]), false );
the question that, how can access menuitems within admin menuitem?
thanks.
here solution , working example:
in order take control on submenu item need navigate using xml expressions , point first element of list. because xml-expression delievers xmllist in common case.
<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600"> <fx:script> <![cdata[ [bindable]public var menuagroapp:xmllist = <> <menuitem label="admin"> <menuitem label="option 1"/> <menuitem label="option 2"/> <menuitem label="option 3"/> <menuitem label="option 4"/> </menuitem> <menuitem label="prices"> <menuitem label="price 1"/> <menuitem label="price 2"/> <menuitem label="price 3"/> </menuitem> <menuitem label="orders"> <menuitem label="order 1"/> <menuitem label="order 2"/> </menuitem> </>; protected function ononoffadmin(event:mouseevent):void { mymenubar.datadescriptor.setenabled(menuagroapp[0], false); } protected function ononoffadminoption2(event:mouseevent):void { mymenubar.datadescriptor.setenabled(menuagroapp[0].menuitem.(@label == 'option 2')[0], false); } ]]> </fx:script> <s:vgroup x="30" y="30"> <mx:menubar id="mymenubar" labelfield="@label" dataprovider="{menuagroapp}"/> <s:spacer height="20"/> <s:button label="set off admin" click="ononoffadmin(event)" /> <s:button label="set off admin/option2" click="ononoffadminoption2(event)" /> </s:vgroup> </s:application>
Comments
Post a Comment