一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

flash 加载xml入门实例教程

时间:2010-11-17 编辑:简简单单 来源:一聚教程网

flash 加载xml入门实例教程

在这篇文章中我们将使用一个xml文件,该文件描述了一个照相馆。的xml存储照片的标题和图像文件的位置


www.111com.net/photo1.jpg" />


在flash action增加

var myphoto:xml;
myphoto = new xml();


当我们创建xml对象,我们可以调用load()函数来加载我们的xml文件

var myphoto:xml;
myphoto = new xml();
myphoto.load("gallery.xml");

看一款实例

var myphoto:xml;
myphoto = new xml();
myphoto.ignorewhite = true;
myphoto.onload = processxmldata;
myphoto.load("gallery.xml");stop();

现在来判断xml是否加载成功

function processxmldata(success){
 if (success)  {   
  mytext.text="gallery loded";
 }  else  {  
  mytext.text="can not load gallery";
     }
 }
 
 
 var mynode;
 mynode = this.firstchild;
 
 取第一个节点名称
 var galleryname;
 galleryname = this.firstchild.attributes.name;
 
 节点长度
 
 var numberofimages;
 numberofimages = this.firstchild.childnodes.length;
 
 获取第一个节点的子节点
 
 var imgname;
 var imglocation;
 imgname     = myphoto.firstchild.childnodes[2].attributes.name;
 imglocation = myphoto.firstchild.childnodes[2].attributes.location;

热门栏目