Wed, 24 May 2006. 找找吧
吧台 读吧 链接 留言 设计沙龙 BT Men
找找吧
 
Photoshop . Flash . Asp . Dreamweaver . Css . Html . JavaScript . Xml . Flash AS . WEB标准 . Illustrator . Sql . WEB配色 . Access . ASP.NET 2.0 . VBScript . Xslt . Rss . Swift3D . IIS . Wap . WEB2.0 . .Net . Flsh AS .
‹ 2006年 Web 2.0 将面临的10个问题 动画制作 动画制作 今天看了个“大眼睛网站” ›
flashMX2004 XML基础篇
心情不错 water 整理于 :53 来自: webstudio 晴天 作者:    Large Medium Small
flash可以读取的XML文件有两种
第一种是-----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<books clss = "类别" na ="书名" author= "作者" pub="出版社">
<book>
<clss>计算机</clss>
<na>thinking in java</na>
<author>dou</author>
<pub>机械工业</pub>
</book>
<book>
<clss>外语</clss>
<na>朗文英语词典</na>
<author>dou</author>
<pub>商务印书馆</pub>
</book>
</books>
--------------------------
对应的程序是:
var myXML:XML = new XML()
myXML.ignoreWhite = true
myXML.load("ce-1-11-8.xml")
myXML.onLoad = function(success:Boolean) {
if (success) {
var rootNum:Number = myXML.firstChild.childNodes.length;
var rootfirstChildNum:Number = myXML.firstChild.firstChild.childNodes.length;
trace("第一个节点有 "+rootNum+"个节点")
trace("第一个节点的第一个节点有 "+rootfirstChildNum+"个节点")
trace("******************************")

for(i=0;i<rootfirstChildNum;i++){
var mmXML= myXML.firstChild.firstChild.childNodes[i].firstChild
trace(mmXML.nodeValue)
}//end for

//var m0XML= myXML.firstChild.firstChild.childNodes[0].firstChild

} else {
trace("Unable to load XML")
}//end if
}//end function
-------------------------
输出是
第一个节点有 2个节点
第一个节点的第一个节点有 4个节点
******************************
计算机
thinking in java
豆豆
机械工业

************************************************
第二种是-----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<books clss = "类别" na ="书名" author= "作者" pub="出版社">
<book clss= "计算机" na="thinking in java" author="豆豆" pub="冰豆出版社"/>
<book clss= "植物" na="植物组织培养" author="豆豆" pub="冰豆出版社"/>
</books>
--------------------------
对应的程序是
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.load("ce-2-11-8.xml");
myXML.onLoad = function(success:Boolean) {
if (success) {
var rootNum:Number = myXML.firstChild.childNodes.length;
trace("第一个节点有 "+rootNum+" 个子节点")
var rootNode = myXML.firstChild.childNodes;
//trace(rootNode)
for(i=0;i<rootNum;i++){
var clss:String = rootNode[i].attributes.clss;
var na:String = rootNode[i].attributes.na
var author:String = rootNode[i].attributes.author
var pub:String = rootNode[i].attributes.pub
trace(i+" node类别 "+clss)
trace(i+" node书名 "+na)
trace(i+" node作者 "+author)
trace(i+" node出版社 "+pub)

}
} else {
trace("Unable to load XML");
}//end if
}//end function
----------------------------------
其中第二种格式,在flash中输出的是:

第一个节点有 2 个子节点
0 node类别 计算机
0 node书名 thinking in java
0 node作者 豆豆
0 node出版社 冰豆出版社
1 node类别 植物
1 node书名 植物组织培养
1 node作者 豆豆
1 node出版社 冰豆出版社
===========================================
【总结】网络上有很多的教程,偶在学习的时候按原样拿人家的东东,可是就是做不出来,而且有很多的大虾采用第二种方式,也就是读取xml的属性的方式。在我看来,第一种方式比较好,因为可以和其他的后台程序互通。
Tags (标签) 引用通告地址 (0)  
Tags: Flash | Xml
复制引用地址http://www.gogogo8.com/ver2/Blog/trackback.asp?tbID=75
复制引用地址http://www.gogogo8.com/ver2/Blog/trackback.asp?tbID=75&CP=GBK
暂时没有评论
发表评论 - 注意输入验证码![本站已启用NoFollow标签]
作者:
用户:  密码:   注册?  验证:  
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
表  情
 
32 active user(s) in 10 minites. 0 member(s). 32 guest(s). 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 游客 Guest 回到页面顶部
Mainly Powered by L-Blog , Styled & Modified by water . © 2005 . Processed in 0.078125 second(s) , 10 queries .
Name : Water  QQ : 26998026  MSN : linweb  Web : http://www.gogogo8.com/ 
用户名:   

密   码:   
     IT新动态 (45) RSS 2.0
     平面设计 (170) RSS 2.0
     VS 2005 (5) RSS 2.0
     动画制作 (40) RSS 2.0
     网页制作 (83) RSS 2.0
     编程开发 (59) RSS 2.0
     帮助文档 (7) RSS 2.0
     品吧好站 (30) RSS 2.0
     乱七八糟 (42) RSS 2.0

   

   

     2005年, 12月份
     2005年, 11月份
     2005年, 10月份
     2005年, 9月份
     2005年, 5月份
     2005年, 4月份
     2005年, 3月份
     2005年, 2月份
     2005年, 1月份


 
BLOG编码找找吧
共同创作协议RSS 2.0
找找吧 | Http://www.gogogo8.com/--为广大WEB设计、制作、开发爱好者提供原创并搜集精品文章的小站:平面设计-动画制作-网页制作-编程开发 Archive

gogogo8.com v 4_3