Flex1
Flex基礎知識點。 MenuBar labelField=@property。 使用@獲取屬性值。 <mx:Script>
????<![CDATA[
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
??????public function menuHandle(event:MenuEvent):void
??????{
????????Alert.show(event.item.@label);
??????}
????]]>
??</mx:Script>
????
??<mx:MenuBar id="mb" fontSize="12" labelField="@label" x="429" y="94" itemClick="menuHandle(event)">
????<mx:XMLList id="dataList" xmlns="">
????????
??????<meunitem label="JAVA">
????????<menuitem label="JDBC" />
????????
??????</meunitem>
????????
??????<meunitem label=".NET">
????????<menuitem label="WINFORM" />
??????</meunitem>
????????
??????<meunitem label="設計">
????????<menuitem label="photoshop" />
??????</meunitem>
????????
????</mx:XMLList>
??</mx:MenuBar> 對于菜單(MenuBar),統(tǒng)一推薦使用itemClick作為事件進行觸發(fā)。 通過event.item.@標簽名稱 的方式來獲得用戶所選擇的值 使用{變量名}可以拿到該組件對象。 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCollection()">
????
??<mx:Script>
????<![CDATA[
??????import mx.collections.XMLListCollection;
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
????????
??????// 導入類
??????import mx.collections.ArrayCollection;
????????
??????// 全局變量
??????public var menuBarCollection:XMLListCollection;
????????
??????// 私有變量
??????private var menuBarXML:XMLList =
????????
??????// 這里,使用<>來標識數(shù)據(jù)????
??????<>
????????<mx:XMLList id="dataList" xmlns="">
????????
????????<meunitem label="JAVA">
??????????<menuitem label="JDBC" data="testJDBC" />
????????????
????????</meunitem>
????????
????????<meunitem label=".NET">
??????????<menuitem label="WINFORM" />
????????</meunitem>
????????
????????<meunitem label="設計">
??????????<menuitem label="photoshop" />
????????</meunitem>
????????
????????</mx:XMLList>
??????</>
????????
????????
??????public function initCollection():void
??????{
????????// 創(chuàng)建集合對象,并注入到menuBarCollection中。
????????menuBarCollection = new XMLListCollection(menuBarXML);
??????}
????????
????????
??????public function menuHandle(event:MenuEvent):void
??????{
????????Alert.show(event.item.@label);
????????Alert.show(event.item.@data);
??????}
????]]>
??</mx:Script>
????
??<mx:MenuBar id="mb" fontSize="12" labelField="@label" x="429" y="94" dataProvider="{menuBarCollection}" itemClick="menuHandle(event)">
????
??</mx:MenuBar>
????
</mx:Application>
彈出式菜單:popUpMenu <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
??<!-- 自定義css樣式,樣式屬性參考幫助手冊中的屬性說明-->
??<mx:Style>
????Alert{
??????title-style-name:"alertTitle";????/* 引用屬性 */
??????message-style-name:"alertMessage";
??????button-style-name:"alertButton";
????}
????.alertTitle {
??????fontSize:12;
??????fontColor:#FFFFFF;
????}
????
????.alertMessage {
??????fontSize:14;
??????fontColor:#FFFFFF;
????}
????
????.alertButton {
??????fontSize:12;
??????fontColor:#FFFFFF;
????}
??</mx:Style>
????
??<mx:Script>
????<![CDATA[
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
??????public function getValue(event:MenuEvent):void {
????????Alert.show(event.item.@label , "提示信息");
??????}
????]]>
??</mx:Script>
????
??<mx:XMLList id="pop_data" xmlns="">
????<editItem label="中文" />
????<editItem label="英文" />
????<editItem label="法文" />????????
??</mx:XMLList>
????
??<mx:PopUpMenuButton id="pu2" dataProvider="{pop_data}" labelField="@label" fontSize="12" itemClick="getValue(event)"/>
????
</mx:Application>
????<![CDATA[
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
??????public function menuHandle(event:MenuEvent):void
??????{
????????Alert.show(event.item.@label);
??????}
????]]>
??</mx:Script>
????
??<mx:MenuBar id="mb" fontSize="12" labelField="@label" x="429" y="94" itemClick="menuHandle(event)">
????<mx:XMLList id="dataList" xmlns="">
????????
??????<meunitem label="JAVA">
????????<menuitem label="JDBC" />
????????
??????</meunitem>
????????
??????<meunitem label=".NET">
????????<menuitem label="WINFORM" />
??????</meunitem>
????????
??????<meunitem label="設計">
????????<menuitem label="photoshop" />
??????</meunitem>
????????
????</mx:XMLList>
??</mx:MenuBar> 對于菜單(MenuBar),統(tǒng)一推薦使用itemClick作為事件進行觸發(fā)。 通過event.item.@標簽名稱 的方式來獲得用戶所選擇的值 使用{變量名}可以拿到該組件對象。 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCollection()">
????
??<mx:Script>
????<![CDATA[
??????import mx.collections.XMLListCollection;
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
????????
??????// 導入類
??????import mx.collections.ArrayCollection;
????????
??????// 全局變量
??????public var menuBarCollection:XMLListCollection;
????????
??????// 私有變量
??????private var menuBarXML:XMLList =
????????
??????// 這里,使用<>來標識數(shù)據(jù)????
??????<>
????????<mx:XMLList id="dataList" xmlns="">
????????
????????<meunitem label="JAVA">
??????????<menuitem label="JDBC" data="testJDBC" />
????????????
????????</meunitem>
????????
????????<meunitem label=".NET">
??????????<menuitem label="WINFORM" />
????????</meunitem>
????????
????????<meunitem label="設計">
??????????<menuitem label="photoshop" />
????????</meunitem>
????????
????????</mx:XMLList>
??????</>
????????
????????
??????public function initCollection():void
??????{
????????// 創(chuàng)建集合對象,并注入到menuBarCollection中。
????????menuBarCollection = new XMLListCollection(menuBarXML);
??????}
????????
????????
??????public function menuHandle(event:MenuEvent):void
??????{
????????Alert.show(event.item.@label);
????????Alert.show(event.item.@data);
??????}
????]]>
??</mx:Script>
????
??<mx:MenuBar id="mb" fontSize="12" labelField="@label" x="429" y="94" dataProvider="{menuBarCollection}" itemClick="menuHandle(event)">
????
??</mx:MenuBar>
????
</mx:Application>
彈出式菜單:popUpMenu <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
??<!-- 自定義css樣式,樣式屬性參考幫助手冊中的屬性說明-->
??<mx:Style>
????Alert{
??????title-style-name:"alertTitle";????/* 引用屬性 */
??????message-style-name:"alertMessage";
??????button-style-name:"alertButton";
????}
????.alertTitle {
??????fontSize:12;
??????fontColor:#FFFFFF;
????}
????
????.alertMessage {
??????fontSize:14;
??????fontColor:#FFFFFF;
????}
????
????.alertButton {
??????fontSize:12;
??????fontColor:#FFFFFF;
????}
??</mx:Style>
????
??<mx:Script>
????<![CDATA[
??????import mx.controls.Alert;
??????import mx.events.MenuEvent;
??????public function getValue(event:MenuEvent):void {
????????Alert.show(event.item.@label , "提示信息");
??????}
????]]>
??</mx:Script>
????
??<mx:XMLList id="pop_data" xmlns="">
????<editItem label="中文" />
????<editItem label="英文" />
????<editItem label="法文" />????????
??</mx:XMLList>
????
??<mx:PopUpMenuButton id="pu2" dataProvider="{pop_data}" labelField="@label" fontSize="12" itemClick="getValue(event)"/>
????
</mx:Application>
轉(zhuǎn)載于:https://blog.51cto.com/xiaosa/152769
總結(jié)
- 上一篇: ***病毒的隐藏方式
- 下一篇: 疼恨皇明热水器的无耻!