views:

78

answers:

1

I have a large xml passed from grails to flex. When flex receives the xml, it converts the xml into an associative array object. Given the large xml file, it takes too long to complete the loop, is there any way in flex to make conversion faster? Below is my sample code.

<xml>
   <car>
      <model>Vios</model>
      <type>Sedan</type>
      <color>Blue</color>
   </car>
   <car>
      <model>Camry</model>
      <type>Luxury</type>
      <color>Black</color>
   </car>
</xml>

*converted to the flex associative array below.*
[Vios].type = Sedan
      .color = Blue
[Camry].type = Luxury
       .color = Black

*Below is a code I used in flex to convert the xml to the associative array object*
var tempXML=xml.children()
var tempArray:Array= new Array()
for(var i:int=0;i<tempXML.length();i++)
{
   tempArray[tempXML[i].@model]= new Object();
   tempArray[tempXML[i].@model].color = tempXML[i][email protected]();
   tempArray[tempXML[i].@model].type = tempXML[i][email protected]();
}
A: 

You can set the HTTPService resultFormat to array. Than you should get an array straight away (parsed by Flex, it still may take some time)

Robert Bak
How can I set the resultFormat to create the associative object array I created above?
Anthony Umpad
Probably "object". You can see the whole list here:http://livedocs.adobe.com/flex/3/langref/mx/rpc/http/HTTPService.html#resultFormat
Robert Bak