I would use xml for something like this, but it can be done with url encoded strings.
Assuming you loaded your data with URLLoader and specified the dataFormat as URLLoaderDataFormat.VARIABLES, you are close.
If you have a raw string, you should parse it first to break it down to name/value pairs. This is what URLVariables does.
Anyway, once you have an object containing names/values, you can do:
var i:int;
for (i = 0; i < 355; i++)
{
var tempString:String = "vote" + i;
voteResults[i] = event.target.data[tempString];
}
If you use dot access, it will take "tempString" literally. If you use bracket access, the value of the variable tempString will be evaluated.
PS: By the way, I don't think your php will do what you want. A cleaner way, IMO would be:
$pairs = array();
for ($i = 0; $i < 355; $i++)
{
$pairs[] = 'vote' . $i . '=' . $votesArray[$i];
// you might want to use rawurlencode($votesArray[$i]) to be safe if these are not numeric values.
}
echo implode('&',$pairs);
PS 2: Also, this is rather brittle since you're hardcoding 355. If you ever change your php, you'll have to change your AS code as well. You could try something like this:
var data:URLVariables = event.target.data as URLVariables;
for(var fieldName:String in data) {
var index:int = parseInt(fieldName.substr(4));
// or optionally, add an underscore to the name: vote_1
// so you can change the above to something like
// fieldName.split("_")[1]
voteResults[index] = data[fieldName];
}
Or, as I said before, you could use xml, which is simple enough and a better option for this, I think.