我在Spark面板中有一个菜单栏,我想通过使用Actionscript选择其中一个菜单项我不知道如何定位其中一个项目。这是我的组件代码的摘录。
<?xml version="1.0" encoding="utf-8"?>
<s:layout>
<s:BasicLayout />
</s:layout>
<fx:Script>
<![CDATA[
import events.CustomMenuEvent;
import mx.collections.ArrayCollection;
import mx.events.MenuEvent;
public function update(id:String):void
{
// This is where I would call the menu to update the button
// from its mediator.
}
protected function appMenu_itemClickHandler(event:MenuEvent):void
{
var data:String = event.item.@data;
var menuEvent:CustomMenuEvent = new CustomMenuEvent(CustomMenuEvent.ITEM_CLICKED);
menuEvent.toggled = Boolean(event.item.@toggled == "true");
menuEvent.data = data;
dispatchEvent(menuEvent);
}
]]>
</fx:Script>
<fx:Declarations>
<fx:XMLList id="menuXML">
<fx:menuitem label="File">
<fx:menuitem label="Open" data="open"/>
<fx:menuitem label="Exit" data="exit"/>
</fx:menuitem>
<fx:menuitem label="View">
<fx:menuitem label="Map" type="check" data="map"/>
<fx:menuitem label="Flights" type="check" data="flights"/>
<fx:menuitem label="Altitude Graph" type="check" data="altitude"/>
</fx:menuitem>
</fx:XMLList>
</fx:Declarations>
<s:controlBarContent>
<mx:MenuBar id="appMenu"
labelField="@label"
showRoot="true"
dataProvider="{menuXML}"
itemClick="appMenu_itemClickHandler(event)"/>
</s:controlBarContent>