How to Add using Actionscript
Hi,
This may seem to be a simple problem, but I am not sure how to get the
heads and tails from this. I have written up a code snippet that spits out the
values based from the output from an external HTTPService. The variables I
declared are integer types, but when I tried to calculate the total, it always
outputs the "appended string" from the values I have in the XML. What I really
want to see is that it outputs the "total" of the numbers I have in the for
loop by adding it together.
Is there something I have missed here?
I tried doing something like number_lines = xmlList.number_lines so I don't
have to worry about the index number of a particular element in the XML, but
every time when I do this, I get no output f the number and messes up my code.
Is there some way in which I can output the number based on the element name
rather than the index position of it in the XML?
Thanks in advance.
To illustrate, I have attached the XML and Actionscript below:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<log>
<number_lines>2</number_lines>
<sell_manager>
<category>203</category>
<total_incidence>3</total_incidence>
</sell_manager>
<sell_manager>
<category>204</category>
<total_incidence>11</total_incidence>
</sell_manager>
</time_log>
Actionscript:
[Bindable]private var total_incidence:int;
[Bindable]private var number_lines:String;
private function resultHandler(e:ResultEvent):void {
var xmlList:XMLList = new XML(e.result).children();
number_lines = xmlList[0];
total_incidence= xmlList[i].total_incidence;
for (var i=1; i<= number_lines; i++) {
total_incidence += xmlList[i].total_incidence;
Alert.show("There are " + total_incidence + " of
sales","Alert Box");
}
}
|