반응형
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
<mx:Panel width="250" height="250" layout="absolute" horizontalCenter="0" verticalCenter="0">
<mx:Label text="select a menu item." horizontalCenter="0" verticalCenter="-86"/>
<mx:MenuBar labelField="@label" itemClick="menuHandler(event);" dataProvider="{menuBarCollection}" horizontalCenter="0" verticalCenter="-58"></mx:MenuBar>
<mx:Text id="t" horizontalCenter="0" verticalCenter="25"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.events.MenuEvent;
import mx.collections.XMLListCollection;
[Bindable]
public var menuBarCollection:XMLListCollection;
private var menubarXML:XMLList =
<>
<menuitem label="초급" data="top">
<menuitem label="2"/>
<menuitem label="3"/>
<menuitem label="4"/>
<menuitem label="5"/>
</menuitem>
<menuitem label="중급" data="top">
<menuitem label="6"/>
<menuitem label="7"/>
<menuitem label="고급">
<menuitem type="separator"/>
<menuitem label="8" type="radio"/>
<menuitem label="9" type="radio"/>
</menuitem>
</menuitem>
</>;
private function init():void{
menuBarCollection = new XMLListCollection(menubarXML);
}
private function menuHandler(event:MenuEvent):void{
if(event.item.@data != "top"){
var str:String = "";
for(var i:uint=1;i<=9;i++){
str += event.item.@label + "x" + i + "=" + (event.item.@label*i) + "\n";
}
t.text = str;
}
}
]]>
</mx:Script>
</mx:Application>
반응형