This content has been marked as final. Show 6 replies
Flex drives me crazy. I recompiled my application at least 30 times yesterday trying to get this to work, and just now, I recompile, and it works. WTH?!
Now having the same issue in another application - a non-Cairngorm application. I don't get this. The XML is fine, because I was able to import it with an <mx:XML> tag with no RTE. Someone please help....
Well I figured out what might be the problem...
My XML originally only had one <account> node. It started working after I added a second <account> node. I guess it doesn't see it as an Array, unless there is more than one object at the root of what you're trying to set as an ArrayCollection???
This is one of the problems with leaving resultFormat at the default "object" Because Array is an object, the player cannot differentiate between and Array with a single element and an Object. There are workarounds that examine the dataType in the resutl and act accordingly, also wrapping the object in ArrayUtil.toArray()
But that is all crap. Set resultFormat="e4x". In the handler, do:
var xmlResult:XML = XML(event.result);
trace(xmlResult.toXMLString()); //see your xml? Yaay!
Now, you have a choice. You can stay in the xml world, using the XML directly or with XMLList or XMLListCollection. I use this mostly.
If you will be displaying large amounts of data in many visible complex item renderers, consider building your own ArrayCollection. Accessing values of strongly typed objects is significantly faster thatn accessing values from XML nodes. Loop through your xml and populate a strongly typed value object with each node's data. Push this onto an Array. When done, wrap the Array in an Array collection.
I also face dthe same problem in my application and I used mx.utils.ArrayUtil.toArray() function only.
can you please more elaborate that setresultFormat stuff?
better to give an example if possible.
resultFormat is a property of your HTTPService object:
var service:HTTPService = new HTTPService();
service.resultFormat = "e4x"; <- SEE THIS LINE
service.url = "assets/hierarchy.xml";