MenuBar control in Flex

Freelance Flash Developer India Flex Developer Mobile app developer Php developer India

MenuBar control is a horizontal bar of menu items which opens submenu. The submenu will be open until the user selects on other menu item, selects a submenu item,  or clicks outside the menubar area.

Here in this example I provide data for MenuBar control using  <mx:XMLList> tag.

Flex menubar code:-

<mx:MenuBar id=”myMenuBar” labelField=”@label” width=”950″ color=”#060606″ height=”30″
     itemClick=”itemClickHandler(event)” borderColor=”#1D48E8″ horizontalCenter=”0″ themeColor=”#FFFFFF”>
         <mx:XMLList>
            <menuitem label=”first”>
                <menuitem label=”first1″   />
                <menuitem type=”separator” />
                <menuitem label=”first2″/>
                 <menuitem type=”separator” />
                <menuitem label=”first3″/>
                 <menuitem type=”separator” />
                <menuitem label=”first4″/>
            </menuitem>
            <menuitem label=”second”>
                <menuitem label=”second1″ />
                <menuitem type=”separator”/>
                <menuitem label=”second2″/>
                <menuitem type=”separator”/>
                <menuitem label=”second3″/>
                <menuitem type=”separator”/>
                <menuitem label=”second4″/>
            </menuitem>
            <menuitem label=”third”>
                <menuitem label=”third1″ />
                <menuitem type=”separator”/>
                <menuitem label=”third2″/>
                <menuitem type=”separator”/>
                <menuitem label=”third3″/>
                <menuitem type=”separator”/>
                <menuitem label=”third4″/>
            </menuitem>
        </mx:XMLList>
</mx:MenuBar>

Import the MenuEvent in the event class and Alert control from controls.

import mx.events.MenuEvent;
import mx.controls.Alert;

We can get the Index of the selected MenuBar item using myMenuBar.selectedIndex.toString() where myMenuBar is the id of the MenuBar.and Index of the selected submenu by event.index.toString() .

 <mx:Script>
<![CDATA[
import mx.events.MenuEvent; 
import mx.controls.Alert;

private function itemClickHandler(event:MenuEvent) : void
{
     Alert.show(“selected index: ” + myMenuBar.selectedIndex.toString() +
child index: ” + event.index.toString());

}

I appreciate if you like this post, feel free to comment, forward, RT

flex menubar, flex menu control, flex menu example, menu bar in flex, flex menu bar, how to make menu bar in flex.
flex developer India, developers in India, India web development, hire India, web developer

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: