View Full Version : Send and Recive nested array data.
Pandan
09-08-2005, 01:34 PM
I canīt figure out a good way to store/handle data from an nested array.
Here is an exampel of an array that I want to send to a asp page. The asp page then stores it in the db.
aTestArray = [
[
[1,5],
[0,1]
],
[
[4,1],
[4,6]
]
];
The nested array can be in diffrent sizes.
I hade some idea about creating a string from the nested array wich I then stored in the db.
After I store the data I also want to get it from the db.
This with some kind of function that takes the string and creates a nested array in flash.
I am not used to using xml, so I don't know if xml is the best way to do it. Or if should try my idea with a string with some kind of separeators.
Would really appriciate all help I can get!
Sorry for my bad english.
Billystyx
09-08-2005, 02:46 PM
The best method to employ depends a lot on the nature of the information you want to send. It is hard to give advise on how best to formulate the information for retrieval in a server-side script without having a rough idea of how the information is being collected and what is being done with it in asp (as in - the separation of the array on the other end into fields/tables).
billystyx
arianhojat
09-08-2005, 03:49 PM
easiest solution
1. do a Xml.send("blah.asp") or (sendAndLoad() if you need a value like 'success' returned) to an ASP page with XML data you make in flash.
build the XML dynamically in flash which you prob know how to do.
<data>
<array>
<array>
<value>1<value>
<value>5</value>
</array>
<array>
<value>0<value>
<value>1</value>
</array>
....
</array>
....
</data>
then with the xml sent to your asp page parse it how you want,
for all values arrays in main array node (which are arrays)
{
for all values arrays in sub array node (which are still arrays)
{
for all values in the subarrays (now values)
{
extract each value and put into database;
}
}
}
[
then if you need to return a variable like success to flash
Response.Write() the XML to return a value.
Response.Write("<success>")
if problems
Response.Write("<value>failure<value>");
Response.Write("<message>database not connected</message>);
else
Response.Write("<value>success<value>");
Response.Write("<message>SWEET!</message>);
Response.Write("</success>")
then parse that back in Flash with an onLoad Event (after the xml array u send to the asp gets done doing its thing and echos/response.writes xml back to Flash, this event is called)
]
2. use Flash remoting (even though i havent tried it).
You can send complex objects like Arrays into php, do some function to get the values out of that array of arrays and put the info in a database maybe u want complex data to come back into flash like an array of arrays of 1's or 0's depending on if each value in the subarrays was successfully put into database (or you dont have to return anything either if you want).
Y do this instead of XML? ... well if you want actual very complex OOP objects like arrays to be returned TO Flash you would use this...
IF you wanted to get a complex object result after sending your info with the asp/xml solution you would have to send XML back to FLash with response.write's and parse it in Flash, which if the object is huge with data, might take a performance hit. But with Remoting the object you get back to FLash is already a Flash object (no need to parse complex XML).
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.