Flex的Tree的Icon问题,求各位帮忙看看啊,谢谢了

cmc0117 2010-10-26 12:00:48
我的代码是这样的,但是那个tree 的ItemIcon属性设置后没看到任何效果,图片路径是对的,不知道什么问题,运行后还是系统默认的那套Icon,求各位看看解决一下了,谢谢了!
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.treeClasses.TreeItemRenderer;
import mx.events.FlexEvent;

[Bindable]
[Embed(source="cok.jpg")]
public var imgClass1:Class;

[Bindable]
[Embed(source="ic1.jpg")]
public var imgCls:Class;

[Bindable]
[Embed(source="cs.jpg")]
public var itemIcon:Class;

]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->

<s:XMLListCollection xmlns="" id="xmlSource">
<s:source>
<fx:XMLList>
<Organization>
<Node label='Root' value='1'>
<Node label='node1' value='2'>
<Node label='node1node1' value='6'>
<Node label='ddd' value='14'></Node>
</Node>
</Node>
<Node label='asasd2' value='3'>
<Node label='aaaaa' value='7'></Node>
</Node>
<Node label='ccas' value='4'>
<Node label='cawea1' value='8'></Node>
</Node>
<Node label='ccas2' value='5'>
<Node label='gasd1' value='9'></Node>
<Node label='sdfas2' value='10'></Node>
</Node>
</Node>
</Organization>
</fx:XMLList>
</s:source>
</s:XMLListCollection>
</fx:Declarations>
<mx:Tree x="59" y="46" width="220" height="456" id="tree1"
dataProvider="{xmlSource}"
labelField="@label" showRoot="false" itemIcons="{imgCls,itemIcon}"></mx:Tree>


</s:Application>


...全文
214 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cmc0117 2010-10-29
  • 打赏
  • 举报
回复
多谢各位大侠了
passself 2010-10-28
  • 打赏
  • 举报
回复

.LayerTree{
selectionColor: #417597;
folderOpenIcon: Embed(source="1.png");
folderClosedIcon: Embed(source="2.png");
defaultLeafIcon: Embed(source="3.gif");
}

这样就比较不错
mayuanfei 2010-10-27
  • 打赏
  • 举报
回复
改成这样:
<mx:Tree x="59" y="46" width="220" height="456" id="tree1"
dataProvider="{xmlSource}"
labelField="@label" showRoot="false" disclosureClosedIcon="{itemIcon}" disclosureOpenIcon="{imgCls}" ></mx:Tree>

disclosureClosedIcon 节点的关闭
disclosureOpenIcon 节点的打开
defaultLeafIcon 叶子的默认图标
chinazhousheng 2010-10-27
  • 打赏
  • 举报
回复
建议用Css控制
LayerTree{
selectionColor: #417597;
folderOpenIcon: Embed(source="1.png");
folderClosedIcon: Embed(source="2.png");
defaultLeafIcon: Embed(source="3.gif");
}
leemiki 2010-10-26
  • 打赏
  • 举报
回复
楼主说的系统默认图标指什么??

打开关闭时的图标吗,方法很多

1.用folderOpenIcon,folderCloseIcon

2.setItemIcon(item,iconClass,iconClass)

....

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧