当前位置:主页>Flah Ria>文章内容
  • XML 与 V2 Tree 组件实例1
  • 来源:Arul's blog 作者:Arul 2006-07-02 【
FlashAs作品发表>>我要投稿 | FlashAs讨论区>>AS论坛
Flash Media Server学习站>>www.FMScn.com


Arul最近写了一个xml结合v2tree组件的实例.
范例XML,sample.xml:

 
      http://www.shockwave-india.com/blog/?archive=2004_12_05_archive.xml#110221061901793484 
        SE|PY has become my favorite actionscript editor these days. It’
s default color highlighting scheme is very different from Flash IDE. So I’
ve modified it to syntax highlight similar to my actionscri...  
        arul@shockwave-india.com 
        Flash MX/Tools 
        110221061901793484 
  http://www.shockwave-india.com/blog/?
archive=2004_12_05_archive.xml&comments=110221061901793484#c110221061901793484 
        Sun, 05 Dec 2004 11:06:59 GMT       
     
         
  http://www.shockwave-india.com/blog/?archive=2004_12_05_archive.xml#110220816407774710
        I always thought I will be more productive (on my blog) when I’m alone. But I’
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...  
        arul@shockwave-india.com 
        Arul’s Blog/Update 
        110220816407774710 
  http://www.shockwave-india.com/blog/?
archive=2004_12_05_archive.xml&comments=110220816407774710#c110220816407774710 
        Sun, 05 Dec 2004 10:43:04 GMT 
     
     
         
  http://www.shockwave-india.com/blog/?archive=2004_07_18_archive.xml#109038436727337119 
    Brandan Hall wrote the PriorityQueue (pQueue) class in Object Oriented Programming with
ActionScript published by New Riders. I’
ve converted that class to ActionScript 2 which you may download from he...  
        arul@shockwave-india.com 
        Flash MX/Code 
        109038436727337119 
        http://www.shockwave-india.com/blog/?
archive=2004_07_18_archive.xml&comments=109038436727337119#c109038436727337119 
        Wed, 21 Jul 2004 13:29:47 GMT 
     

 

使用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’);
 

就能得到我们想要的结果了.





上一篇:Franky 1.0 - FLEX在线音乐收听应用   下一篇:Flash8新组件FLVPlayback应用 FLV视频调用
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
FLASH源文件

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)