您的 index.php 文件是不必要的。
您的第二个文件不完整。这是他们的“hello world”类文件的文档示例:
<?php
class HelloWorld
{
function HelloWorld()
{
$this->methodTable = array
(
"say" => array
(
"access" => "remote",
"description" => "Pings back a message"
)
);
}
function say($sMessage)
{
return 'You said: ' . $sMessage;
}
}
?>
此文件应保存为与您在 php 文件中命名的“class HelloWorld”匹配的“HelloWorld”(您使用 FlashMe 正确完成了这部分)。
Flash 片(在 actionscript 中)的文档中的示例文件在这里:
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
var gatewayUrl:String = "http://localhost/flashservices/gateway.php"
NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, 'HelloWorld', null , null);
var pc:PendingCall = _service.say("Hello world!");
pc.responder = new RelayResponder(this, "handleResult", "handleError");
function handleResult(re:ResultEvent)
{
trace('The result is: ' + re.result);
}
function handleError(fe:FaultEvent)
{
trace('There has been an error');
}
网关 URL 应该指向可以访问您的服务的任何地方。我敢肯定,如果你尝试几个,你会找到合适的。amfphp 的巧妙之处在于,它还允许您在尝试在网关中实现它们之前测试您的服务(如果您在浏览器中访问 URL)。
我对 AMFPHP 也很陌生,但我发现这些文档非常有用。如果您需要有关课程的更多帮助,可以在PHP 文档页面上找到更多信息。