| To use Flash::FLAP, download it  
and install in the usual way (perl Makefile.PL; make; make install). 
 To build/export .swf files with "Flash Remoting" you need to install
Flash Remoting MX Components  (free download).
This will install the files "NetServices.as" and "NetDebug.as" that are
used in the ActionScript.
 
 
 Sample code that uses Flash Remoting (See also examples that are distributed with the module).
 Client code:
 
 
 //Obligatory includes#include "NetServices.as"
 #include "NetDebug.as"
 
 //Get a connection object
 NetServices.setDefaultGatewayURL("http://host/cpu.pl");
 connection = NetServices.createGatewayConnection();
 
 //Get a pointer to a service
 remoteService = connection.getService("Foo", this);
 
 //Call a remote method on that service
 remoteService.bar();
 
 //or... send arguments to the server:
 remoteService.bar(arg1, arg2);
 
 //This callback function will be invoked
 function bar_result(value)
 {
 //do something with the value
 }
 
 Server code, option A - service registration.
 Use in simple applications.
 
 
use Flash::FLAP;Server code, option B - limited service discovery.
 package Foo;
 
 sub new
 {
 my ($proto)=@_;
 my $self={};
 bless $self, $proto;
 return $self;
 }
 
 sub bar
 {
 my ($self, $arg1, $arg2) = @_;
 my $value;
 
 #Compute a return value
 #...
 
 return $value;
 }
 
 #Create the gateway object
 my $gateway = Flash::FLAP->new;
 
 #Register a service that provides methods.
 #You can register more than one service.
 #This can happen during server startup (if running under mod_perl).
 $gateway->registerService("Foo",new Foo());
 
 #Let the gateway figure out who will be called.
 $gateway->service();
 
 
 Use in complex applications.
 
 Part 1.  The gateway script.
 
 
 use Flash::FLAP;
 
 #Create the gateway object
 
 my $gateway = Flash::FLAP->new;
 
 #Set a directory that will contain Perl package.
 #Each package will correspond to one service -
 #there can be as many as you want!
 #You can set only one class path, though.
 
 $gateway->setBaseClassPath("./basicservices/");
 
 #Let the gateway figure out who will be called.
 
 $gateway->service();
 
 
 
 Part 2.  Sample class in the registered directory.
 package DataEcho;
 
 sub new
 {
 my ($proto)=@_;
 my $self={};
 bless $self, $proto;
 return $self;
 }
 
 
 sub methodTable
 {
 return {
 "echoNormal" => {
 "description" => "Echoes the passed argument back to Flash (no need to set the return t
 ype)",
 "access" => "remote", # available values are private, public, remote
 },
 "echoDate" => {
 "description" => "Echoes a Flash Date Object (the returnType needs setting)",
 "access" => "remote", # available values are private, public, remote
 "returns" => "date"
 },
 "echoXML" => {
 "description" => "Echoes a Flash XML Object (the returnType needs setting)",
 "access" => "private", # available values are private, public, remote
 "returns" => "xml"
 }
 };
 }
 
 sub echoNormal
 {
 my ($self, $data) = @_;
 return $data;
 }
 sub echoDate
 {
 my ($self, $data) = @_;
 return $data;
 }
 sub echoXML
 {
 my ($self, $data) = @_;
 return $data;
 }
 
 1;
 
 
 |