Table of contents:
- What's new
- Installing Remoting components
- Installing AMFPHP
- Testing AMFPHP
- 10,000 foot view of Remoting
- Creating Remoting methods
- Method table reference
- Helper classes
- NetDebug
- Authenticate
- DateWrapper
- Datatypes
- Class mapping
- Security
- Authentication
- Sending recordsets
- Manual recordsets
- Pageable recordsets
- Consuming web services (SOAP)
- Other platforms
- FAME
- Flex
- FlashCom
- The service browser
- Debugging
- Debugging primer
- NetConnection debugger
- Debugging proxies
- NetDebug::trace and exceptions
- Common confusing errors
- Deploying
- Credits
Other platforms
AMFPHP is not restricted to working with swfs made with the Flash IDE. AMFPHP works equally well with MTASC/FAME, FlashCom and Flex
MTASC/FAME
To use MTASC for Remoting, you will need to compile against the Remoting class sources instead of the RemotingClasses component. You will then need to patch the files in a few places to get them rolling with MTASC. Complete instructions are available here.
FlashCom
FlashCom works great with AMFPHP. Although earlier versions had issues with large packets, this was fixed by 1.0MS1 and AMFPHP has been deployed on several FlashCom-intensive sites.
You need to load the netservices.asc file in the scriptlib folder, and then use NetServices much as you would in Flash MX. The syntax is not all that pretty but it works. Here's an example of a login system backed by AMFPHP to get you started:
load("netservices.asc");
application.onConnect = function(clientObject, sessid)
{
//Here the client furnishes a session id lifted from FlashVars so that
//sessions will work
NetServices.setDefaultGatewayUrl(
"http://www.myserver.com/amfphp/gateway.php?PHPSESSID=" + sessid);
trace("Attempting to let user connect");
//Check if this user has access to this particular FlashCom app
nsc = NetServices.createGatewayConnection();
service = nsc.getService("Login", new LoginService(clientObject));
servercall = service.login(clientObject);
}
/**
* LoginService class
* Responder for LoginService service (remoting)
*/
function LoginService(client)
{
this.client = client;
}
LoginService.prototype.login_Result = function(result)
{
trace("Retrieved login from assignVideoId");
if(result.code == "User.Accepted")
{
//Hurray!
application.acceptConnection(this.client);
}
else
{
//There was a fudge
application.rejectConnection(this.client, result);
}
}
NetDebug::trace will not work with FlashCom. This can make debugging challenging. Using a custom logger in PHP is recommended. Some users have had positive experiences using PowerFlasher SOS.
Flex
Flex comes with its own Remoting gateway. You can still use AMFPHP with Flex though, you simply have to explicitely say you want an http service in the RemoteObject tag. Here's an example straight from Jesse Warden:
<!-- endpoint is the location of the gateway file. source is the name of the
service (can be fully qualified like com.mydomain.MyService). AMFPHP does not support
named arguments but you can simply write them as arg1, arg2, etc. -->
<mx:RemoteObject endpoint="http://www.mydomain.com/amfphp/gateway.php"
id="service"
source="MyService"
protocol="http"
showBusyCursor="true">
<mx:method name="doSomething">
<mx:arguments>
<arg1>{txtName.text}</arg1>
</mx:arguments>
</mx:method>
</mx:RemoteObject>
The result will be available in service.doSomething.result.
