PDA

View Full Version : Passing arrays PHP -> Flash


JohnnyS
09-23-2002, 04:26 PM
I want to send an array from PHP to Flash, and I have tried something like this:
for($i=0; $i<$max; $i++){
echo(&flasharray[$i]=$phparray[$i]);}
Flash can pick up flasharray and dynamically print from it - for instance if a text field is set to flasharray[10] it prints fine, BUT I don't think it's really an array, just an object called "flasharray[10] so any attempt to access it, like trying
if(flasharray[i]="Pig" will not work. Can anyone tell me how I should be sending arrays please?

tg
09-23-2002, 04:47 PM
ya, its not really an array, flash imports its vars as strings. split your arrays out on the flash side.

JohnnyS
10-08-2002, 06:32 PM
I have now done it by sending a string from PHP to Flash but there are pitfalls-you are limited to the length of string you can send in one go, and I had to send in 4 chunks. These I stored and split() into 4 arrays which I joined to make my finished array. Another pitfall worth knowing about is this:
for(i in myArray){
...}
i is not an integer! If you try and use it to access arrays, it falls over. You must recast it with Number(i); Hope this helps someone...