Download presentation
Presentation is loading. Please wait.
Published byBeverly Fields Modified over 9 years ago
1
Data-driven Flash Development with AMFPHP David Knape http://bumpslide.com/ http://bumpslide.com/
2
Who am I? PHP Programmer since 1998 Flash Programmer at Second Story Independent Contractor, Consultant Recent Work: –http://designarchives.aiga.org/http://designarchives.aiga.org/ –http://arago.si.edu/http://arago.si.edu/ –http://explorer.monticello.org/http://explorer.monticello.org/ –http://bumpslide.com/http://bumpslide.com/
3
What is Flash Remoting? Toolkit for client/server data exchange and remote method invocation over HTTP. “Web services” with AMF instead of SOAP –Binary Format == Less Bandwidth than XML –Flash Player decodes it quicker than XML –AMF3 is the new Format used by default in Flex 2 Allows Flash and Server to speak the same language. Free and open-source PHP implementations: –AMFPHP – http://amfphp.org/http://amfphp.org/ –WebOrb – http://themidnightcoders.com/http://themidnightcoders.com/
4
Why not use SOAP? SOAP has larger payloads SOAP requires more CPU processing Memory Leak with Flash Web Services API Remoting just works better in the Flash player Benchmarks: http://www.themidnightcoders.com/articles/soap_vs_flash_remot ing_benchmark.htm
5
Getting Started with AMFPHP Unzip amfphp package into server root Create new php class in amfphp/services: <?php class TestService { // @access remote function sayHello( $name ) { return "Hello, ".$name; } } ?> Create Method Table using browser and include in constructor: function TestService(){ include("TestService.methodTable.php"); } Test the Service - http://amfphpdemo/amfphp/browser/http://amfphpdemo/amfphp/browser/
6
RecordSet Object that represents a query result AMFPHP automatically creates recordsets from the result of a database query Flash Remoting classes includes mx.remoting.RecordSet which implements the DataProvider API Flash Components can use recordsets as data providers
7
Paged Recordsets Results sent in batches as needed Allows flash components to show lengthy lists without loading everything at once Example: http://testbed/northwind/swf/
8
ADODB for PHP Database abstraction layer for PHP http://adodb.sourceforge.net/ To use ADODB with AMFPHP: 1. Add adapter mapping for DB-specific AdoRecordset classname 2. Set fetch mode to ‘fetch_num’ $gateway->addAdapterMapping('adorecordset_mysql', 'adodb'); $DbConnection->SetFetchMode( ADODB_FETCH_NUM );
9
Sample App: Gallery Site MySQL Database holds items and references to image files PHP class method queries database and returns the results AMFPHP exposes the PHP Class as a “Service” Actionscript calls the service method via the AMFPHP Gateway
10
Gallery Admin Tool Admin tool built with CakePHP –http://cakephp.org/http://cakephp.org/ Images accessed with phpThumb –http://phpthumb.sourceforge.net/http://phpthumb.sourceforge.net/ see http://amfphpdemo/cake/http://amfphpdemo/cake/
11
Gallery ActionScript GalleryApp – Application Root MovieClip ModelLocator – Application Data / State GalleryService – our service class Clips: Menu – loads service and lays out menu items MenuItem – triggers selectedItem state change Content – loads image when state changes
12
FlashDevelop Free AS editor Code hinting MTASC compiling Code generation Overall improved workflow
13
Bumpslide Library Common Service interface and ServiceProxy State management with observable Model –Similar to AS3 ObjectProxy –Supports one-way data binding Utility classes – com.bumpslide.util See http://bumpslide.sourceforge.net/http://bumpslide.sourceforge.net/
14
References Remoting Components - http://www.adobe.com/products/flashremoting/downl oads/components/ http://www.adobe.com/products/flashremoting/downl oads/components/ Remoting Classes with MTASC - http://www.5etdemi.com/blog/archives/2006/01/gett ing-remoting-running-in-mtasc/ AMFPHP - http://amfphp.org/http://amfphp.org/ FlashDevelop – http://flashdevelop.org/http://flashdevelop.org/ MTASC – http://mtasc.org/http://mtasc.org/ WebOrb – http://themidnightcoders.com/weborb/http://themidnightcoders.com/weborb/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.