首页 > 代码库 > 实现flex LinkBar 组件 动态切换ico图标
实现flex LinkBar 组件 动态切换ico图标
<?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>
<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>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。