由XML更新的整数值

时间:2010-02-10 20:21:12

标签: xml flash actionscript-3

如何重新制作swf for xml命令? “Remake”听起来很愚蠢,但我只想让XML文件更新整数值。这可能超出了我的理解范围。我想要一个 例如,混搭或我可以使用的方法。

myThoughts
- 它需要读取XML“解析它等”
- 变量接收e:数据而不是“我与传递值和函数调用的斗争”

XML

//XML
<head>
<seq_no>text</seq_no>
</head>
<body>
<count>0</count>
<timer>10</timer>
<fcount>0</fcount>
</body>

RUBY REXML

msg1 = {"msg" => {"head" => {"type"  => "frctl", "seq_no" => seq_no},
     "body" => {"count" => "0", "timer" => 10, "fcount" => 10000}}}

msg1 = {"msg" => {"head" => {"type"  => "frctl", "seq_no" => seq_no},
     "body" => {"count" => "0", "timer" => 100, "fcount" => 100000}}}

闪存

//Flash "the counter" half of Stackoverflow has participated in writing
var timer:Timer = new Timer(10);  
var count:int = 0; //start at -1 if you want the first decimal to be 0  
var fcount:int = 0; 

timer.addEventListener(TimerEvent.TIMER, incrementCounter);  
timer.start();  


function incrementCounter(event:TimerEvent) {  
  count++;  
  //
  fcount=int(count*count/10000);//starts out slow... then speeds up 
  //
  var whole_value:int = int(fcount / 100); //change value 
  var tenths:int = int(fcount / 10) % 10;   
  var hundredths:int = int(fcount) % 10;   

  mytext.text = whole_value + " : " + tenths + hundredths;  
}   

“希望尽快离开noobsville,让他们来”

1 个答案:

答案 0 :(得分:0)

要打开XML文件,请尝试类似于:

的内容
function processXMLData(success)
{
  if (success)
  {
    var newsNode=this.firstChild;
var headerNode=newsNode.childNodes[0];
var contentNode=newsNode.childNodes[1];
var infoNode=newsNode.childNodes[2];
var authorNode=infoNode.childNodes[1];

header=headerNode.firstChild.nodeValue; 
content=contentNode.firstChild.nodeValue;   
author=authorNode.firstChild.nodeValue;
  }
  else
  {
    content="Today's news is not found";
  }
}

var xmlData=new XML();
xmlData.ignoreWhite=true;
xmlData.onLoad=processXMLData;
xmlData.load("news.xml");
stop();

然后只需将相应的节点分配给变量。您需要验证节点是否具有数据,以及数据是否具有正确的数据类型或能够转换为正确的数据类型。