You are basically trying to convert data from one format to another, so you'll have to loop through all of it.
My previous post contained a rough code for the recommended way of doing what you did. If you define an actual class with fields, you'll get much better performance and type-safety at coding time, plus you should keep your loop limits in a local variable. ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of aceoohay Sent: Saturday, October 27, 2007 10:41 PM To: [email protected] Subject: [flexcoders] Re: How do I convert an object to an arrayCollection? I found what appears to be a generic solution to my problem, but I have a concern about performance. I hope that someone with (as my daughter would say) "some skills" can point out the right way of doing this. My approach is to create a function that will convert any object that looks like the one in the original post to an ArrayCollection suitable for use in a DataGrid. Here is what I came up with; 1st Create a dynamic Class like; package { public dynamic class DynamicClass { } } Next create a function like this; private function loadArrayCollection(objIn:Object):ArrayCollection { var acTmpArray:ArrayCollection = new ArrayCollection; for (var i:Number = 0;i < objIn.initialData.length;i++) { var clTempClass:DynamicClass = new DynamicClass(); for (var j:Number = 0;j < objIn.columnNames.length;j++) { clTempClass[objIn.columnNames[j]] = objIn.initialData[i][j]; } acTmpArray.addItem(clTempClass); } return acTmpArray; } Then we call it like this; [Bindable] public var acPERSON:ArrayCollection = new ArrayCollection acPERSON = loadArrayCollection(event.PERSON.serverInfo); and voila we have an arrayCollection that looks and acts remarkably like one created from a HTTPService result set. I still have more testing to make sure I can access all of its properties similar to the way the HTTPService version works. OK, now that I am done patting myself on the back, there must be a better way. It seems to me that this would be slow and resource intensive, and one of the reasons I want to move towards Fluorine is performance. Besides it just looks like a kludge. I am very interested in hearing of better ways of doing this without resorting to hand coding a class for every query I create. Paul

