Datatype Conversions
The conversion of datatypes between PHP and ActionScript is straightforward, as shown in Table 9-1. These conversions work in both directions, from PHP to ActionScript and vice versa, with the exception of PHP arrays.
The conversion of PHP arrays to Flash ActionScript can be a bit confusing. In PHP, all arrays are associative arrays . Associative arrays can use any type of symbol, rather than just integers, for the index. This means that the following PHP code is perfectly legal:
$myList = new Array( ); $myList[0] = "apple"; $myList["foo"] = 12;
This fact means that, when coming from Flash, ActionScript objects of type Array and Object (a.k.a. structures) are converted to the PHP Array datatype. When converting an ActionScript Array to PHP, a PHP Array using entirely integer indexes is created.
The problem comes when translating PHP arrays to ActionScript. AMFPHP has to guess what is the best kind of ActionScript datatype to create from the PHP array. It does this by a simple process of elimination; if the PHP array contains any noninteger indexes, it is converted to the ActionScript Object datatype; otherwise, it is converted to the ActionScript Array datatype.
As of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access