你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
shiyang12345
赞同来自:
var xmlString="<data>"+ "<dir name='shi' num='10000' state='已集结' time_pro='' isOpen='true'>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "</dir>"+ "<dir num='shi' ok='dsasddsfsasdad' isOpen='true'>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "<file num='1000' ok='ok' isOpen='true'/>"+ "</dir>"+ "</data>"; var xml = this.parseXMLFromString(xmlString); console.log(this.m_tree) this.m_tree.xml =xml;
cuixueying
// 组装tree的数据 var treeData:String = "<data>"; for(var i:int = 0; i < 5; ++i) { //在xml里添加一个控制透明度的属性,自定义命名,此处叫isAlpha treeData += "<item label='Directory " + (i + 1) + "' isOpen='true'"+" isAlpha='0.5'>"; for(var j:int = 0; j < 5; ++j) { treeData += "<leaf label='File " + (j + 1) + "'/>"; } treeData += "</item>"; } treeData += "</data>";
tree.renderHandler=new Handler(this,onTreeRender); // 返回值e代表的是item项 private function onTreeRender(e):void { //获取每条Item的alpha属性并赋值给Item对象 if(e._dataSource.isAlpha) { var alphaNum:Number=e._dataSource.isAlpha; e.alpha=alphaNum; }//如果未设置alpha的项,则默认透明度为1 else { e.alpha=1; } }
要回复问题请先登录
2 个回复
shiyang12345
赞同来自:
cuixueying
赞同来自:
1、在xml里,给你的项添加一个关于alpha的属性,譬如isAlpha 2、为你的tree添加一个渲染函数renderHandler,在渲染函数下根据你的alpha值对每条项进行属性赋值 附件已经上传,可以参考,把alpha改成你对应的visible属性即可!