Integer values updated by XML
How do I remake my swf for xml commands? "Remake" sounds silly, but I just want to have integer values updated by an XML file. This may be beyond my understanding. I'd like an example, a mash-up, or method I can work from.
myThoughts
- It needs to read XML "parse it etc" - variables receive e:data instead "my struggle with passing values and function calls"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
//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 / 10开发者_如何学编程0); //change value
var tenths:int = int(fcount / 10) % 10;
var hundredths:int = int(fcount) % 10;
mytext.text = whole_value + " : " + tenths + hundredths;
}
"hoping to be out of noobsville soon, keep em' coming"
To open an XML file try something similar to:
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();
Then just assign the corresponding nodes to your variables. You will want to validate that the node has data and that the data is in the correct data type or able to cast to the correct data type.
精彩评论