Datatype Conversions

The Flash Remoting gateway translates ActionScript objects to Java objects when passing ActionScript objects as method parameters for Remoting service method calls. When it gets the results of the service call, the gateway translates the Java object results to ActionScript objects for Flash. It does these translations regardless of the service type and according to the mappings listed in Tables Table A-3 and Table A-4 in Appendix A.

There are specialized behaviors in these translations that are worth describing here.

ActionScript-to-Java Data Conversion

The Remoting gateway converts objects from ActionScript to Java arbitrarily deep. This means that a graph of nested objects in ActionScript will become a graph of nested objects in Java, converted according to the mappings listed in Table A-3. Because the gateway traverses nested ActionScript objects to do the conversion, it is possible to cause a java.lang.StackOverflowException in the gateway by passing objects with recursive references. This example shows one way to get into trouble:

var service = gatewayConnection.getService(
                  "com.oreilly.frdg.java.service.JavaClassService", this);

// Create two objects that reference each other.
var top = new Object( );
var bottom = new Object( );
top.bottom = bottom;
bottom.top = top;

// Creates a stack overflow because of infinite recursion
// when the gateway tries to convert the objects to Java
service.echo(top);

While the preceding example is oversimplified, it is not ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.