<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    xmlns:local="*"
     viewSourceURL="srcview/index.html">
    
    <mx:Script>
        <![CDATA[
            
            protected function handleRadioButtonClick(event:MouseEvent):void
            {
                if (event.target.label == "Boss")
                {
                    currentState = "boss";
                }
                else
                {
                    currentState = "";
                }
            }
            
        ]]>
    </mx:Script>

    <mx:ArrayCollection id="actions">
        <mx:Object label="Check Inventory" />
        <mx:Object label="Transfer Product" />
        <mx:Object label="Request Vacation" />
    </mx:ArrayCollection>

    <mx:MenuBar dataProvider="{actions}" />

    <mx:Spacer height="200" />

    <mx:HBox>
        <mx:RadioButton 
            label="Employee"
            selected="true"
            groupName="state"
            click="handleRadioButtonClick(event)"
            />
        <mx:RadioButton 
            label="Boss"
            selected="false"
            groupName="state"
            click="handleRadioButtonClick(event)"
            />
    </mx:HBox>

    <mx:states>
        <mx:State name="boss">
            <local:AddItem 
                target="{actions as ArrayCollection}" 
                relativeTo="{actions.getItemAt(1)}" 
                position="after"
                >
                <mx:Object label="Send Fax" />
            </local:AddItem>
            <local:AddItem 
                target="{actions as ArrayCollection}" 
                position="lastItem"
                >
                <mx:Object label="Decline Vacation" />
            </local:AddItem>
        </mx:State>
    </mx:states>
    
</mx:Application>