Actionscript 3.0 Tutorial


All Apache Thrift tutorials require that you have:

  1. The Apache Thrift Compiler and Libraries, see Download and Building from Source for more details.
  2. Generated the tutorial.thrift and shared.thrift files:
    thrift -r --gen as3 tutorial.thrift
  3. Followed all prerequisites listed below.



To initialize client you can use code similar to:

    private function initConnection():void {
      mTransport = new TSocket("", 9090); // we connect to server;
      // initialize protocol:
      var protocol:TProtocol = new TBinaryProtocol(mTransport, false, false);
      mCalculatorClient = new CalculatorImpl(protocol); // finally, we create calculator client instance


The example client above can be tested against a java tutorial server.

Additional Information

You might find server failing due to out of memory exception. This might happen because of flash crossdomain policy. See next passage on how to fix this.

Flash crossdomain policy

Flash does not allow movies to connect to arbitrary servers. This is done for security reasons. To override this restriction, however, servers’ owners can create special file - crossdomain xml file, which lists the rules according to which some flash movies can connect to the server.

Details about this behavior are listed in Setting up a socket policy file server. Also, you can find a simple python/perl server script to serve this file there. For same host, you can serve crossdomain.xml from any port. So, you can start your RPC servers on ports 9090 and 9091, and serve polisy file from port 9092. To tell flash about this, you can use code from tutorial file:

    private function initSecurity():void {

Example of crossdomain file, to allow connect to ports 9090 and 9091 from any server:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<!-- Policy file -->
  <allow-access-from domain="*" to-ports="9090,9091" />