Here is a small example of AMFPHP and PHP interaction to download AMFPHPfor? If you are using other FLASH8 components, please download them here: http://www.adobe.com/products/flashremoting/downloads/components/after the installation is downloaded, a small example of opening the interaction between AMFPHP and PHP is displayed.
Download AMFPHP? Flash 8 components, if you use other versions, please choose to download here: http://www.adobe.com/products/flashremoting/downloads/components/
After the download and installation are complete, open Macromedia Flash 8 and check "window | Public Library | Remoting" to see the AMFPHP component.
Create a new project, drag a RemotingClasses component to any place on the stage, drag a List component, name it myls, drag a Button component, and name it "mybt"
Copy the following code in the first line:
import mx.remoting.*;import mx.rpc.*;import mx.utils.Delegate;import mx.remoting.debug.NetDebug;var gatewayUrl:String = "http://localhost/amfphp/gateway.php";var service:Service;NetDebug.initialize();service = new Service(gatewayUrl, null, "PersonService");function getPerson() { trace("getPerson"); var pc:PendingCall = service.getPerson(); pc.responder = new RelayResponder(this, "handleGetPerson");}function handleGetPerson(re:ResultEvent) { trace("handleGetPerson"); trace(re.result.getItemAt(0).name); _root.mytree.dataProvider = re.result; _root.mydg.dataProvider = re.result;}function onClick() { getPerson();}mybt.addEventListener("click", Delegate.create(this, onClick));
Create a new file named PersonService. php in the SERVICES folder of AMFPHP.
Copy the content to PersonService. php.
methodTable=array( "getPerson"=> array( "access"=>"remote" ) ); mysql_connect('localhost','root','wuliqunao'); mysql_select_db('test'); } function getPerson() { $sql="SELECT * FROM persons"; $query=mysql_query($sql); return $query; }}?>
? Now, release your program and click the Button. The result is displayed:
Of course, your local machine needs to have a MYSQL data, which contains a test database, which creates a persons data table, two fields in the table, one is name and the other is age. (The table tells me that you are not good at this database. search for a MYSQL database Getting Started Tutorial and you will know it .)
Now, we are done. start learning the path of AMFPHP ~~~~
Starting with php -- sendToURL of communication tutorial basics
Http://bbs.actionscript3.cn/thread-8144-1-3.html
Flash Communication tutorial-URLLoader Class 1
Http://bbs.actionscript3.cn/thread-8230-1-2.html
Flash Communication tutorial-URLLoader class 2-background
Http://bbs.actionscript3.cn/thread-8243-1-2.html
Flash Communication tutorial URLLoader class 3?
Http://bbs.actionscript3.cn/thread-8245-1-2.html
Flash Communication tutorial URLLoader class 4
Http://bbs.actionscript3.cn/thread-8246-1-2.html
Flash Communication tutorial URLLoader class 5-xml?
Http://bbs.actionscript3.cn/thread-8247-1-2.html
Flash Communication tutorial URLLoader Class 6
Http://bbs.actionscript3.cn/thread-8248-1-2.html
Flash Communication tutorial URLLoader class 7-request with data
Http://bbs.actionscript3.cn/thread-8249-1-2.html
Example of mutual communication between php and flex
Http://bbs.actionscript3.cn/thread-10726-1-2.html
Flash: getting php variables
Http://bbs.actionscript3.cn/thread-6494-1-1.html
Http://hi.baidu.com/pcbbt/blog/item/4018f64ecb9fa3dbd1c86ac1.html
Http://www.51xflash.com/article/flashcs3/200812/14-8057.html
Http://www.codehorde.com/thread-1628-1-1.html