| Flash Media Server学习站>>www.FMScn.com |
Arul最近写了一个xml结合v2tree组件的实例.
范例XML,sample.xml:
s default color highlighting scheme is very different from Flash IDE. So I’ ve modified it to syntax highlight similar to my actionscri... 110221061901793484 archive=2004_12_05_archive.xml&comments=110221061901793484#c110221061901793484 http://www.shockwave-india.com/blog/?archive=2004_12_05_archive.xml#110220816407774710 m wrong this time. I couldn’t do much when my family was away. Now they are back and I’ m also back in this blog :) Meanw... 110220816407774710 archive=2004_12_05_archive.xml&comments=110220816407774710#c110220816407774710 http://www.shockwave-india.com/blog/?archive=2004_07_18_archive.xml#109038436727337119 ActionScript published by New Riders. I’ ve converted that class to ActionScript 2 which you may download from he... 109038436727337119 archive=2004_07_18_archive.xml&comments=109038436727337119#c109038436727337119 |
使用tree组件来展示xml并不麻烦,因为在MX2004中,tree组件是基于xml的.
第一步:
根据上面的xml文件,我们拖入一个tree组件,命名为tree.
在第一帧写下如是代码:
| import mx.controls.Tree; var tree:Tree; var sample_xml:XML = new XML(); sample_xml.ignoreWhite = true; sample_xml.onLoad = function(done) { if (done) { tree.dataProvider = this; } }; sample_xml.load(’sample.xml’); |
现在这个tree组件是这样的:
因为tree组显示xml的节点需要lable,但是并没有在xml中给到,下面是解决方案.
| import mx.controls.Tree; var tree:Tree; //icon function is added here tree.labelFunction = function(node) { return node.nodeType == 1 ? node.nodeName : node.nodeValue; }; var sample_xml:XML = new XML(); sample_xml.ignoreWhite = true; sample_xml.onLoad = function(done) { if (done) { tree.dataProvider = this; } }; sample_xml.load(’sample.xml’); |
就能得到我们想要的结果了.
admin#flashas.net (#为@) 联系QQ:
:40777822
浙ICP备06033001号