<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:ns="http://www.taxinfo.com"
height="600"
width ="800"
creationComplete="init()"
>
<fx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
[Embed(source=‘xmbz.png‘)]
private var imgs:Class;
private var arr:Array = [{name:"1. LinkBar常用属性、方法和事件",value:"1"},{name:"2.通用例子",value:"2"},{name:"3.Flex中如何通过iconField样式,给LinkBar添加Icon图标",value:"3"},{name:"参考文献:",value:"4"}]
private function init():void{
this.myLink.dataProvider = arr;
}
protected function linkbar1_itemClickHandler(event:ItemClickEvent):void
{
trace( JSON.stringify(arr[event.target.selectedIndex])+"----------------")
trace( event.target.selectedIndex+"----------------")
for(var i:int = 0;i<arr.length;i++){
if(i==event.target.selectedIndex){
arr[event.target.selectedIndex].ico = imgs;
}
else{
arr[i].ico = null;
}
}
this.myLink.dataProvider = arr;
}
]]>
</fx:Script>
<mx:LinkBar id="myLink" direction="vertical" labelField="name" iconField="ico"
itemClick="linkbar1_itemClickHandler(event)" >
</mx:LinkBar>
</s:WindowedApplication>