1 person found this helpful
The lazy way might not work in this situation. You may have to loop through event.result and assign each object to an instance of a locally defined class that you add to your array collection. Just a few more lines of code.
I think if you need to use dataBinding you will have to define the class of the objects in the array and in that class definition, you need to indicate [Bindable].
Then, you should be able to use dataBinding on the instances of that class.
for (var i:int = 0; i< event.result.length; i++)
var rec:VOMyClass = new VOMyClass();
rec = parseMyClass(event.result[i]); // or maybe rec = event.result[i] as VOMyClass ...
Units.addItem( rec );
Thanks Pierre, you're a saviour! I dont know why i didnt think of that on time!
But one quick question...
Dont you think it would have performance draw backs...what if i'm returning a thousand objects from the remote service. Note that. The RemoteObject is being requested every 40 seconds, so during every 40 seconds, my list gets updated with new units. ( I'm doing a GPS tracker in which a small flex Android App in sends details of the mobile device's location every 60 seconds to a mysql database. then a flex application reads this data and pin points its location. I'm using Google maps 3D API for flash to Achieve this). The system has been created in such a way that as more mobile phones join the system, the flex app is able to know and mark its location on the map...I'm trying to simulate real time mapping.
Please tell me what you think and how i can make this better!
If all the Objects in the arrays you are getting down are as simple as GPS location records (Lat, Long, ID) then the parsing should not affect you too much.
You may be getting thousands of records down the first time, but there would be no reason to get thousands of records each time, if you make your automatic call smart enough to only ask for new data (so ask the MySQL DB for records newer than the last time I got records) then you are lessening the number or records you get down, and you can just keep appending the new records to the arrayCollection.
If performance is an issue, then you may want to define the Objects on the server in a way that Flex can automatically detect & deserialize on the client, AMFPHP and ZendAMF support this.
for incoming objects you can just use a remote class alias
to pass typed objects in both directions you need to map the class in the gateway
Wade Armold explains it nicely for zend amf, I guess it will work for amfphp