Sending Arrays with offset Index.

Last time we saw the problem with sending ActionScipt 3 Associative Array. Now we let us see where associative arrays can help.
Lets Make an Array with offset index in PHP:

$arr =array(5=>5);

in ActionScript:

var arr:Array= [];
arr[5]=5;

Sending these arrays either way they go with the missing indices filled with null, so the PHP array comes to flash as

arr=[null, null, null, null, null, 5];

flash array goes to PHP as

$arr=array(NULL, NULL, NULL, NULL, NULL, 5);

This happens in AS1 and AS2 remoting as well.
For an offset of 5 this may be fine, but think about 1000 and above. Solution to this problem is simple, we just need to convert this to associative array by defining one string based key, then the unwanted null values will be gone.

Leave a Reply