Here's one way to do it.  The cool thing is that, in this example, the XML enabled attribute actually binds to the control's enabled property (good thinking Adobe).  If you're using Cairngorm, you can also use this method to dispatch XML defined menu events.

Cheers,
Tim Hoff

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
    width="100%" height="100%">

    <mx:Script>
          <![CDATA[

                import mx.events.MenuEvent;
                import org.ets.main.code.model.ModelLocator;
                import org.nevis.cairngorm.control.CairngormEvent;
   
                private function handleTopMenu(event:MenuEvent):void
                {
                    var cairngormEvent:CairngormEvent = new CairngormEvent(
[EMAIL PROTECTED]);
                    dispatchEvent(cairngormEvent);       
                }
         
           ]]>
    </mx:Script>
  
    <mx:XML format="e4x" id="topMenuData">
        <root>
             <menuitem label="Search" enabled="true">
                  <menuitem label="Authors" enabled="true" event="showSearchAuthors"/>
                  <menuitem label="Plagiarists" enabled="false" event="showSearchPlagiarists"/>
             </menuitem>
             <menuitem label="Reports" enabled="true">
                  <menuitem label="Authors" enabled="true" event="printAuthors"/>
                  <menuitem label="Plagierists" enabled="false" event="printPlagiarists"/>
             </menuitem> 
         </root>
    </mx:XML>
 
    <mx:ApplicationControlBar width="100%">
          <mx:MenuBar id="topMenuBar"    
                 height="100%" width="100%"
                 dataProvider="{topMenuData}"
                 showRoot="false" labelField="@label"
                 change="handleTopMenu(event);">       
          </mx:MenuBar>
    </mx:ApplicationControlBar>
 
</mx:Canvas>


--- In [email protected], "Wally Randall" <[EMAIL PROTECTED]> wrote:
>
> I have a large menu with about 100 different nodes and sub-nodes. I
> am trying to design a means of enabling the menu nodes at run-time
> rather than hardcoded in the mxml menu application.
>
> I envisage having the menu call a ColdFusion CFC to dynamically build
> the menu menubarXML list with the user-specific options enabled from
> the Application creationComplete event.
>
> Does anyone have an example of how to do this in AS3?
>
> Is this the best way of handling this type of menu?
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to