All XML attribute values, names, and text values are String data types, and you
may need
to convert these to other data types. For example, the following code uses the
Number()
function to convert text values to numbers:
var myXML:XML =
<order>
<item>
<price>3.95</price>
</item>
<item>
<price>1.00</price>
</item>
</order>;
var total:XML = <total>0</total>;
myXML.appendChild(total);
for each (var item:XML in myXML.item)
{
myXML.total.children()[0] = Number(myXML.total.children()[0])
+
Number(item.price.children()[0]);
}
trace(myXML.total); // 4.35;
If this code did not use the Number() function, the code would interpret the +
operator as
the string concatenation operator, and the trace() method in the last line
would output the
following:
01.003.95
-- Taken from Adobe Flex 3 Help File
Hope this helps,
David
--- In [email protected], "Rafael Faria" <[EMAIL PROTECTED]> wrote:
>
> Any reason why HTTPService when return my XML as an Object transform
> the following array into strings that was suppose to contain strings
>
> <item key="version">
> <label><![CDATA[Version]]></label>
> <type><![CDATA[dropdown]]></type>
> <source>
> <item key=""><![CDATA[Choose]]></item>
>
> <item key="2.0"><![CDATA[2.0]]></item>
> <item key="1.2"><![CDATA[1.2]]></item>
> <item key="1.0"><![CDATA[1.0]]></item>
> </source>
> <default><![CDATA[Choose]]></default>
> <width><![CDATA[100]]></width>
> <rules><![CDATA[trim|required]]></rules>
> </item>
>
> I'm populating my combobox with the "source" node. I'm using
> HTTPService and the resultFormaat = "object".
>
> It adds but whenever i have 1.0 or 2.0 flex just assume it's an string
> and use "1 or 2" removing the .0.
>
> there is anyway to tell flex to NOT remove that i want an string and
> not an integer?
>
> raf
>