Flash Remoting AS2 vs AS3

One of the new things that was changed in Flash CS3/Actionscript3.0 was the way that flash remoting is handled. In AS2, You needed to create a pendingCall to your service’s method(s) and access them that way. In AS3, you make a direct call to the service’s method.

For details, and code examples on the changes, keep reading.
In actionscript2.0 land, the code that you would normally use to make a Flash remoting connection would look something like this-

var myResponder:RelayResponder = new RelayResponder(this,"onResult","onFault");
var myService:Service = new Service("",null,"HelloWorld",null,myResponder);
var temp_pc:PendingCall = myService.("Hello World!");

Now, in AS3.0, things have changed a little bit. Using Flash CS3, your code would look something like this, for a generic remoting example-

import flash.net.*; //Required for all the netConnection classes
var myService:NetConnection = new NetConnection();
myService.objectEncoding = ObjectEncoding.AMF0;
var responder = new Responder(onResult,onFault);
var var1:String = "variable1";

One of the most important lines is the last one. The actual CALL to your method. In order to pass variables to the remoting connection, you just append them at the end of the call string like I did above.

About Curious Minds
We are a web development firm in New York and Chicago, providing development resources and consulting for websites and mobile apps since 2004.