Normally, people use RemoteObject to talk to a remoting destination in BlazeDS which is a class part of Flex framework but once in a while, I get questions on whether it’s possible to do remoting with Flash’s NetConnection directly. Although using NetConnection has no immediate benefits, it’s helpful in case one does not want to use Flex framework or simply prefer using NetConnection.
Thanks to LegacyFilter in BlazeDS, this is indeed possible. Here’s an outline of what you need to do. First, create a NetConnection and connect to the URL of the endpoint you need to connect (which is defined in services-config.xml)
var nc:NetConnection = new NetConnection();
nc.connect("http://localhost:8400/team/messagebroker/amf" );
Then, do the NetConnection call with a special parameter, result/fault responders, and arguments to the remoting method.
nc.call( "remoting_AMF.echo", new Responder( resultHandler, faultHandler ), "hello");
The first parameter is important, the format is destinationId and method name seperated by a dot. In this example, we’re asking BlazeDS to direct the request to destination with id “remoting_AMF” and the “echo” method of the class that the destination exposes. LegacyFilter handles the rest. A full example is here in BlazeDS source tree.