Code I: Server Side C# Class

namespace Flashorb.Examples
{
  public class SampleClass
  {
    public int EchoInteger( int i )
    {
    return i;
    }
  }
}

Code II: Client-side ActionScript

1 #include "NetServices.as"
2 
3 conx = NetServices.createGatewayConnection
( "http://remoting server url" );
4 service = conx.getService( "Flashorb.Examples.SampleClass", this );
5 service.EchoInteger( 5 );
6 
7 function EchoInteger_Result( result )
8 {
9  trace( "received back " + result );
10 }

Code III
 
namespace Flashorb.Examples
{
  public class HRDepartment
  {
    public Employee AddEmployee( Employee emp )
    {
    // some business logic here
    return emp;
    }
  }

  public class Employee
  {
  String Name;
  String Title;
  long Salary;  
  }
}

Code IV: Client side ActionScript

1 #include "NetServices.as"
2
3 conx = NetServices.createGatewayConnection( "http://remoting server url" );
4 service = conx.getService("Flashorb.Examples.HRDepartment", this );
5
6 var employee = new Object();
7 employee.Name = "Joe Orbman";
8 employee.Title = "Chief Architect";
9 employee.Salary = 200000;
10 service.AddEmployee( employee );
11
12 function AddEmployee_Result( result )
13 {
14 trace( "received back employee " + result.Name );
15 }

Shutting down unsecure Java VM
#include "NetServices.as"
conx = NetServices.createGatewayConnection( "http://remoting server url" );
service = conx.getService( "java.lang.System", this );
service.exit( 1 );

Shutting down unsecure .NET application
#include "NetServices.as"
conx = NetServices.createGatewayConnection( "http://remoting server url" );
service = conx.getService( "System.Environment", this );
service.Exit( 1 );

Code V: Server Side C# Classes

1 namespace Flashorb.Examples
2{
3  public class RemoteReferenceClass : Flashorb.IRemote
4  {
5     private string data;
6
7     public void IRemote getRemoteReference()
8     {
9       return this;
10     }
11
12     public void setData( string data )
13     {
14       this.data = data;
15     }
16
17     public string getData()
18     {
19       return data;
20     }
21  }
22 }

Code VI: Client-side ActionScript

1 #include "NetServices.as"
2
3 conx = NetServices.createGatewayConnection( "http://remoting server url" );
4 service = conx.getService("Flashorb.Examples.RemoteReferenceClass", this );
5 service.getRemoteReference();
6
7 function getRemoteReference_Result( result )
8 {
9  this.remoteReference = result;
10  // calling remote method
11  this.remoteReference.setData( "Remote References are cool" );
12 }
13
14 function setData_Result( result )
15 {
16  this.reference.getData();
17 }
18
19 function getData_Result( result )
20 {
21  // should print "Remote References are cool"
22  trace( result );
23 }