AMFPHP入门教程.doc

上传人:鲁** 文档编号:561777783 上传时间:2024-01-28 格式:DOC 页数:21 大小:205.72KB
返回 下载 相关 举报
AMFPHP入门教程.doc_第1页
第1页 / 共21页
AMFPHP入门教程.doc_第2页
第2页 / 共21页
AMFPHP入门教程.doc_第3页
第3页 / 共21页
AMFPHP入门教程.doc_第4页
第4页 / 共21页
AMFPHP入门教程.doc_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《AMFPHP入门教程.doc》由会员分享,可在线阅读,更多相关《AMFPHP入门教程.doc(21页珍藏版)》请在金锄头文库上搜索。

1、AMFPHP入门教程。 不想传递拆分字符串,解析串行XML了吧?厌烦JSON了?试试AMF吧,传送多种数据格式。首先下载AMFPHP(本教程使用1.9BETA2)你可以选择其他版本 在这里选择下载下载后,解压缩,把文件夹中的amfphp文件夹拷贝到 APACHE服务器的网站根目录。然后打开浏览器,输入http:/localhost/amfphp/gateway.php 确定如果提示:amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.Note: If yo

2、ure reading an old tutorial, it will tell you that you should see a download window instead of this message. This confused people so this is the new behaviour starting from amfphp 1.2.View the amfphp documentationLoad the service browser说明安装成功。打开网站根目录的AMFPHP文件夹,进入SERVICES文件夹,新建一个PHP文件命名为HELLOWORLD.p

3、hp拷贝以下代码:methodTable=array(say=array(access=remote,description=Pingsbackamessage);functionsay($sMessage)returnYousaid:.$sMessage;?保存!在浏览器地址栏输入http:/localhost/amfphp/browser/回车AMFPHP的项目管理器:单击 HelloWorld看到一下内容,就是HELLOWORLD项目具体内容:在sMessage输入内容(比如xiaoxiaocainiao), 单击call按钮:看到页面下方的提示结果:好了,你已经初步学会安装AMFPHP

4、并使用了,具体的语法,函数,还需要查看一下官方的文档啦。下面一起来做一个FLASH通过AMFPHP和PHP交互的小例子:到这里下载AMFPHP forFLASH8的组件,如果你使用其他版本,请到这里选择下载:http:/ ,查看 “窗口|公用库|Remoting”就可以看到AMFPHP的组件了。新建立一个工程,拖一个RemotingClasses组件到舞台的任何地方,再拖一个List组件,命名为myls,拖一个Button组件,命名为mybt在第一帧的代码行复制以下代码:importmx.remoting.*;importmx.rpc.*;importmx.utils.Delegate;imp

5、ortmx.remoting.debug.NetDebug;vargatewayUrl:String=http:/localhost/amfphp/gateway.php;varservice:Service;NetDebug.initialize();service=newService(gatewayUrl,null,PersonService);functiongetPerson()trace(getPerson);varpc:PendingCall=service.getPerson();pc.responder=newRelayResponder(this,handleGetPers

6、on);functionhandleGetPerson(re:ResultEvent)trace(handleGetPerson);trace(re.result.getItemAt(0).name);_root.mytree.dataProvider=re.result;_root.mydg.dataProvider=re.result;functiononClick()getPerson();mybt.addEventListener(click,Delegate.create(this,onClick);在AMFPHP的SERVICES文件夹下新建一个文件,命名为PersonServic

7、e.php复制一下内容到PersonService.phpmethodTable=array(getPerson=array(access=remote);mysql_connect(localhost,root,wuliqunao);mysql_select_db(test);functiongetPerson()$sql=sprintf(SELECT*FROMpersons);$query=mysql_query($sql);return$query;?好了,发布你的程序,单击Button按钮,看到结果:当然了,你的本机需要有个MYSQL数据有,里面简历一个test数据库,这个库里面创建一

8、个persons数据表,表里2个字段,一个是name,一个是age.(表告诉我,你搞不好这个库啊,搜一个MYSQL数据库入门教程,一下就知道啦。)好了,大功告成,开始学习AMFPHP之路吧AMFPhp 与 Flex Builder3 的交互(一)写一下php与Flex的交互。作为学习笔记,现在这方面中文文档貌似比较少。下面的大多数都来自http:/www.sephiroth.it 。英文好的同学可以直接去看。 好,先说一下我的基本配置吧。php 版本:php-5.2.6-Win32.zip,apache版本:apache_2.2.8-win32-x86,mysql版本:mysql-5.0.51

9、a-win32.具体的配置方法就不说了,去网上搜吧,太多了。我的本地服务放在 D:php。 好,ok。 在http:/ amfphp-1.9.beta.20070513.zip 。下载后,解压到我的本地服务目录,即 D:php 。然后再浏览器中输入:http:/localhost/amfphp/gateway.php 如果你看到了如下信息,就说明安装成功了。amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.AMF C Extension is loade

10、d and enabled.Note: If youre reading an old tutorial, it will tell you that you should see a download window instead of this message. This confused people so this is the new behaviour starting from amfphp 1.2.View the amfphp documentationLoad the service browser 好了,让我们写一个HelloWorld程序吧。首先打开D:phpamfph

11、pservices目录,新建一个HelloWorld.php文件,在文件中输入以下代码: 1. 复制代码好啦,php端,就先这样了。然后我们写flex端的吧。在Flex builder3新建一个Flex工程。 需要注意的是,在Application server type选择php。呵呵,下一步。 在web root 下填入 D:php 即我的本地web服务的目录。root url 填入:http:/127.0.0.1 即本地IP啦,呵呵。然后下一步,如果你不改源文件的目录的话,就直接Finish啦。 好,在src里再新建一个xml文档,名字叫: services-config.xml ,打开,输入以下代码,这个flex与amfphp的配置文件。 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. *11. 12. 13. 14. 15. 16.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号