hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
    Articles
  Flash streaming servers  Flash button as Flex icon  Flex form by email  Hello Remoting with AS3  AS3 Saving data from Flash  AS3 Loading data into Flash  Fire Effect  Contact form  Dragable buttons  Hello World with openamf  Loading helper classes  Upload with Flash 8  Transitions effects  Snapshot with Flash 8  Hello World Remoting AS2  Flash AS2 Remoting Connector  Saving data from Flash  Loading data into Flash  FlashCom & Remoting login  Cell Renderer API  Editing a table using remoting components  Flash MX2004 web service classes  Browsing a catalog  amfphp Documentation  Hello World Remoting  Online Store with AMFPHP  Flash clients for Web Services  Web Service Walk Though with NuSoap  Popup windows in flash with javascript  Installing Apache/PHP  MoreOver News Feeds  Load Edit Save Text Files via CGI  Save Movie Clip Postion via PHP and MySQL
Current Page (1) Next Page >> 1 | 2 | 3 | 4

An Introduction to Flash Remoting

By: Jorge Solis

Visit the amfphp flash remoting message board for up to date (amfphp is still in development) and helpful tips (amfphp can either be really easy or really hard to setup and use the first time). The documentation for amfphp 0.9.0 beta is also online here.

What is Flash Remoting?

Flash Remoting allows flash movies to call remote server side applications, passing parameters and recieving requests, without knowledge of the server side. The calls are usually named Remote Procedural Calls (RPCs), and transfer serialized, type-persistent objects directly between the server and a Flash MX client. Developers on both sides (flash and server) collaberate on ways of calling methods in order to build the system. With AMF (Action Message Format) the exchange of information is faster and allows you to pass objects (not only name/value pairs) between Flash and the server in binary format. This allows you to easily develop complex applications that rely on an efficient way of sending and recieving data.

Flash Remoting was first available as a native ColdFusion feature, then extended to .Net and J2EE Application Servers. But recently one of the Forum Administrators here in Flash-db (Wolfgang aka Musicman) exposed the binary format of the AMF packet. This opened the door for the AMFPHP Project, where developers have been building an open source library to port Flash Remoting to PHP. This project will allow Flash developers to use Flash remoting in a PHP environment, and with (almost) the same functionality as Macromedia's version. Other developers have also begun to port flash remoting to other languages such as Java (see http://www.openamf.org/) and Perl (see http://www.simonf.com/flap/)

You can follow also an interesting discussion about Flash Remoting here

Installing Flash Remoting for PHP (aka amfphp)

First install the Flash remoting components. The components include the classes you need to connect to Flash remoting, and also debugging and formatting classes that will help out when developing.

Next download the current version of AMFPHP from http://amfphp.sourceforge.net/. We will try to update this tutorial as the AMFPHP project matures. For this tutorial we will be working in a Windows environments, in the near future we will try to put up information for both Linux and Mac OS's (there's not much of a difference).

After you have downloaded the current version of AMFPHP unzip them and take a look at the files. You will see two folders: examples and flashservices. The most important is flashservices, and inside it are all the amfphp files. In the app folder, there is a file called Gateway.php. This file builds the communication between the application and the amfphp library, we need to correctly point to it in order to work with the complete services. This path is the most important consideration that we need to keep in mind when building our service. The service should have: a gateway php that points to the flashservices/app/Gateway.php and a base Class that points to our service. This second file is really the service we're writing for our application. Here's how an example gateway.php file would look:


    <?php 
          
include ("../flashservices/app/Gateway.php");
          
$gateway = new Gateway ();
          
$gateway ->setBaseClassPath ("services/");
          
$gateway ->service();
    
?>

Here's a quick tip from the AMFPHP project:

Using apache Aliases for one gateway for every virtualhost on your system.
Create an alias in apache for your gateway.php
Alias /gateway.php /path/to/my/gateway.php 
The gateway code looks like this:

    <?php 
        
include("/path/to/your/flashservices/app/Gateway.php");
        
$gateway = new Gateway();
        
$gateway->setBaseClassPath($_SERVER["DOCUMENT_ROOT"] . "/");
        
$gateway->service();
    
?>

For the example we need to create a folder for our application (named Hello) on the same level as the flashservices folder. So in the first line, we go a step above to look for the flashservices folder (relative to this file). Then, we need to create a services folder inside our application folder (named Hello) to store all our own services and set it as the BaseClassPath for our service. Here's a screen shot of our folder structure. Inside the Hello folder (that we have created for holding our example) is the application, and inside it is the services holder that we created to put the the service we are creating. The arrows indicate the files inside each folder. Right now just create the structure of folders and the above php script (gateway.php). You may also want to quickly look over the examples in the 'examples folder', these will also help you on your way.

Let's take a look for the Mac OSX  users!

Download example files >>>

Current Page (1) Next Page >> 1 | 2 | 3 | 4