Avg. Rating 3.4

Problem

Flex 2 introduced a newer Action Message Format that does not work with Flash Media Server.

Solution

To connect with older ActionScript 2.0 applications, you need to force the NetConnection and SharedObject to use AMF0 encoding instead of the default AMF3.

Detailed explanation

To connect to Flash Media Server (FMS), the Flash client uses NetConnection and SharedObject components. In Actionscript 3.0 and Flex 2 these components use AMF3 by default. FMS at this time only supports AMF0. You must force Flex 2 clients to use the AMF0 encoding in either of the following two methods.
var nc:NetConnection = new NetConnection(); nc.objectEncoding = flash.net.ObjectEncoding.AMF0; 
or
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0; 
The first method changes the object encoding for the instantiated object only where as the second method changes the object encoding for all NetConnection’s globally.

Note: Another change is the NetConnection and NetStream are not dynamic classes in AS 3.0.  To receive return messages you need to use the client property and declare each method on the client properties object instance.
Report abuse

Related recipes