这节来看一下amfphp,下载后,解压得到一个amfphp的文件夹,将它放到网站根目录(注意PHP环境要配置好),这样就配置好了,配置比较简单。
在浏览器上输入:http://localhost/amfphp/gateway.php
在浏览器上显示如下文字,就配置好了。
amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.
Note: If you're 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 documentation
Load the service browser
Note: If you're 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 documentation
Load the service browser
amfphp有一好处是可能调试你写的remoting,这样你不用写FLASH端,就可以知道你的REMOTING写的是不是正确的了,点击上面的文字的最下面一行链接,Load the service browser 就可以进入了,或者在浏览器上输入:http://localhost/amfphp/browser/index.html
同样写一个简单PHP端代码:
<?
php
class Hello
{
function Hello()
{
}
function sayHello( $nameStr )
{
return " hello! " . $nameStr ;
}
}
class Hello
{
function Hello()
{
}
function sayHello( $nameStr )
{
return " hello! " . $nameStr ;
}
}
生成一个Hello.php文件,我们要放在amfphp里的services目录里,这里我们在services里建一个上一节中的目录结构net/smilecn/helloWorld,然后将Hello.php放在helloWorld里
FLASH端的代码只需要改一句代码:
把
private
var gateWayUrl:String
=
"
http://localhost:8080/flashService/gateway
"
;
改成
private
var gateWayUrl:String
=
"
http://localhost/amfphp/gateway.php
"
;
就可以了,其它代码不用变。
下节继续。
(本教程如需转载请注明出处!)