Understanding FLASH and RPC with AMFphp: Integration of ActionScript and PHP
This article explores the integration of ActionScript and PHP using AMFphp, providing essential insights into Remote Procedure Call (RPC) between client and server. Learn about the in's and out's of connecting Flex, JavaScript, Ajax, and XML, as well as practical implementations and real-time examples. We discuss how AMFphp processes requests, security checks, and serialization of return data. Additionally, the article covers various use cases such as data visualization, CRM systems, and dynamic web applications, along with valuable resources for further exploration.
Understanding FLASH and RPC with AMFphp: Integration of ActionScript and PHP
E N D
Presentation Transcript
Andrew Giles FLASH and RPC using AMFphp
What are we talking about here? • A simple integration of actionscript and php. • Also integrates Flex, Javascript, Ajax, XML. • The in's and out's • Uses and Ideas • Resources • A real-time example
RPC? • Remote Procedure Call • Communication between client and server by setting a callback and receiving a result. • How AMFphp does it... • Perform request • Deserialize request • Finds the corresponding remote class • Instantiates the class • Performs security checks • Calls the remote method using the specified arguments • Serializes the returned data
Getting Started actionscript... • Include the required classes import mx.remoting.debug.NetDebug; import mx.remoting.*; import mx.rpc.*; NetDebug.initialize(); • Create the servicevar service:Service = new Service('http://localhost/amfphp/gateway.php', null, 'com.company.MyService'); • Create the remote methodvar pc:PendingCall = service.myMethod("arg1", {x:'myX'}); pc.responder:RelayResponder = new RelayResponder(this, "onSuccess", "onFault"); • Handle the resultfunction onSuccess(re:ResultEvent){ trace("Success!"); } function onFault(){ trace("Fudge! :("); }
Getting Started php... <?php class HelloWorld { function HelloWorld() { $this->methodTable = array ( "say" => array ( "access" => "remote", "description" => "Pings back a message" ) ); } function say($sMessage) { return 'You said: ' . $sMessage; } } ?>
Example Uses and Ideas • Data Visualization • Online/Intranet CRM • Content Management Systems • RFID/Database Integration • Web Services • RSS • Dynamic Gaming Environments • Real Estate and MLS websites • Website file system automation
Advantages? • Object Oriented • Real-time feedback • Consistent layouts and interactivity • Cross browser/platform compatibility • Stand-alone projector applications
Resources • http://www.amfphp.org/ • http://www.sephiroth.it/ • http://www.flash-db.com/ • http://www.macromedia.com/devnet/mx/flashremoting/