c# 加载flash脚本_Flash脚本-将XML数据加载到Flash中

c# 加载flash脚本

Here, I’ll show you how to load xml data into Flash. Note that this tutorial assumes that you have a very good knowledge of xml. Download the sample files here.

在这里,我将向您展示如何将xml数据加载到Flash中。 请注意,本教程假定您对xml有很好的了解。 在此处下载示例文件

1. Let’s start by creating a xml document. Open notepad and insert:

1.让我们开始创建一个xml文档。 打开记事本并插入:

<?xml version="1.0" encoding="iso-8859-1"?>
  <xmltest>
      <parentnode>
        <node1>First node value</node1>
       <node2>Second node value</node2>
       <node3>Third node value</node3>
       <node4>Fourth node value</node4>
       <node5>Fifth node value</node5>
      </parentnode>
  </xmltest>

2. Save the file as flash.xml.

2.将文件另存为flash.xml。

3. Open a new movie in Flash. I have set the movie properties at width:370 and height:200.

3.在Flash中打开新电影。 我已将影片属性设置为宽度:370和高度:200。

4. Now, create dynamic text, and give it a variable name "txt". Be sure to check html in the text options pallete.

4.现在,创建动态文本,并为其指定变量名称“ txt”。 确保检查文本选项面板中的html。

5. Right click on the first and only frame in the movie, and select Actions. Insert:

5.右键单击影片中的第一帧和唯一一帧,然后选择“动作”。 插:

XML_var = new XML();
// now load up the url.
XML_var.load("http://www.flashcircle.com/swffiles/flash.xml");
// when xml is loaded call functon displayXML
XML_var.onLoad = displayXML;
// display in txt xml is loading
txt = "Loading XML data...";
function displayXML()  
{
mainTag = new XML;
elementTag = new XML;
articleList = new Array;
elementList = new Array;
mainTag = this.firstChild.nextSibling;
articleList = mainTag.childNodes;  
txt = "";
//loop through xml
for(i=0;i<=articleList.length;i++)
{//start for
elementList = articleList[i].childNodes;
//start for
for(j=0;j<=elementList.length;j++)  
{//start for
elementTag = elementList[j];
head = elementTag.firstChild.nodeValue;
if(elementTag.nodeName.toLowerCase() == "node1")
{txt += head +"";}
if(elementTag.nodeName.toLowerCase() == "node2")
{txt += head +"";}
if(elementTag.nodeName.toLowerCase() == "node3")
{txt += head +"";}
if(elementTag.nodeName.toLowerCase() == "node4")
{txt += head +"";}
if(elementTag.nodeName.toLowerCase() == "node5")
{txt += head +"";}
}//end for
}//end for
}

Let me explain how each line works.

让我解释一下每一行的工作方式。

XML_var = new XML()
...declare XML_var as a new xml object.
XML_var = new XML()
...declare XML_var as a new xml object.

翻译自: https://www.sitepoint.com/script-load-xml-data-flash/

c# 加载flash脚本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值