Posted on Thursday 29 September 2005
Call a service method like so:
import mx.remoting.Service;
var service:Service = new Service('http://localhost/gateway.php', null, 'MyService');
var evilArray = new Array();
evilArray[0xfffffff] = true;
service.myMethod(evilArray);
Why does this crash the player and the IDE? Remoting serializes arrays without encoding indices; so if it encounters a very large index, it will fill the rest with an 'undefined' flag. So Flash is attempting to write approximately 200 megabytes worth of 0x06 into the stream and 'for some odd reason' it doesn't work. It actually happened to me by accident, just so you know. Which brings us to the workaround: force Flash to type as a MixedArray instead of as an array, thus sending the keys and not attempting to maintain sparsity the 'cheap way'. This can be done using a dummy index in the array, for example:
import mx.remoting.Service;
var service:Service = new Service('http://localhost/gateway.php', null, 'MyService');
var evilArray = new Array();
evilArray['evilFix'] = true;
evilArray[0xfffffff] = true;
service.myMethod(evilArray);
Problem solved! This is actually quite useful to know if you need to send sparse arrays over Remoting.


