dongtun1209 2010-07-09 12:37
浏览 54
已采纳

实例化AMF PHP类无法正常工作

I am trying to use AMF PHP to pass variables to a flash file, thus far I cannot see anything wrong with my code, but I have very little experience with creating classes, so here it goes, here is my code,

index.php:

<?php
include "amfphp/services/flashMe.php";

$session = true;

if ($session == true) {
 $uid = '12345';


  $thing = new flashMe;
  $thing->push($uid);

} else {

 //login

}

?>

flashMe.php:

<?php
class flashMe {

 public function __construct() {

 }

 public function push($one)
 {   
    return $one;//sends the uid to the flash file?
 }

}
?>

Flash is looking for the flashMe class and the push method within that class, but I keep getting null variables in my flash file when I run it, is there something wrong with this code?

Thanx in advance!

  • 写回答

3条回答 默认 最新

  • doutuosai3504 2010-07-19 19:39
    关注

    Your index.php file is unnecessary.

    Your second file is incomplete. Here is the example from the docs for their "hello world" class file:

    <?php
    class HelloWorld
    {
        function HelloWorld()
        {
            $this->methodTable = array
            (
                "say" => array
                (
                    "access" => "remote",
                    "description" => "Pings back a message"
                )
            );
        }
    
        function say($sMessage)
        {
            return 'You said: ' . $sMessage;
        }
    }
    ?>
    

    This file should be saved as "HelloWorld" matching the "class HelloWorld" you have named in the php file (you did this part right with FlashMe).

    The example file in the docs for the Flash piece (in actionscript) is here:

    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');
    }
    

    The gateway URL should go to wherever your services can be reached. I'm sure if you try a few you'll find the right one. The neat thing about amfphp is that it allows you to also test your services out before you try implementing them in the gateway (if you go to the URL in your browser).

    I'm pretty new to AMFPHP as well, but I've found the docs to be extraordinarily useful. If you need more help on classes, you can find more info on the PHP docs page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决