Red5 Remoting

So now our application class looks like this :

Application class with service class registration
Application class with service class registration

Step 5:  –  Create a method that will be called by client. To do this we just add a function to our handler class called “sayHello()“. This method is a simple method which takes no parameters, rather just returns “Hello” to calling client.

public String sayHello()
return "Hello";

So finally our service class, RemoteMethods looks like this:

Service Class
Service Class

That’s it for our server side setup !!

Creating a flash/flex client:

Now that our Red5 code is set up, we move on to creating our service caller – The Flash/Flex Client.




<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute" applicationComplete="application1_applicationCompleteHandler(event)">
import com.remoting.RemotingConnection;

import mx.controls.Alert;

private var conn:RemotingConnection;

protected function application1_applicationCompleteHandler(event:FlexEvent):void
conn = new RemotingConnection('http://localhost:5080/remotingdemo/gateway');

public function asHello():void
{"RemoteClass.sayHello",new Responder(red5service_resultHandler,red5service_faultHandler));

protected function red5service_resultHandler(event:Object):void
asBox.text = event as String;

protected function red5service_faultHandler(event:Object):void
asBox.text = event.fault.message as String;

<mx:TextInput y="188.5" editable="false" width="200" id="asBox" horizontalCenter="0"/>
<mx:Button y="230.5" label="Execute" width="200" height="30" click="{asHello()}" horizontalCenter="0"/>
<mx:Label text="Remoting with Red5" fontFamily="Arial" fontSize="19" color="#FFFFFF" fontWeight="bold" width="266.81818" height="28.030304" textAlign="center" horizontalCenter="0" top="100"/>

Final Discussion:

When we execute our flex interaface you will see that the text box is filled in with “Hello“, as we press the execute button. By default if you are using red5 plugin to create your applications, the web.xml is already setup to support remoting.


Hence when you navigate to :


You will see a message in the browser — “Red5 : Remoting Gateway”. This message confirms that gateway is working fine. Also you may notice that since we registered the service class in root scope, we are connecting to remotingdemo/gateway which is the root scope path by the remoting gateway. To connect to scopes within you use deeper url paths:

ex:  http://localhost:5080/remotingdemo/gateway/subscope

If you want to register a service handler (service class) as a Bean , use the following syntax in the red5-web.xml:

<bean id="RemoteClass.service" class="org.red5.core.RemoteMethods" singleton="true" />

For more info catch up with 🙂

Flash Builder Project File (fxp) Download
Red5 Applciation Download
As3 Remoting Class

If you have trouble getting emails from this domain, please check your email spam & mark messages from as 'Not Spam'

Comments are closed