2010-07-09 49 views
0

我想使用AMF PHP將變量傳遞給一個Flash文件,到目前爲止我看不到任何錯誤的代碼,但是我創建類的經驗很少,所以在這裏,這裏是我的代碼,實例化一個AMF PHP類不工作

的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? 
} 

} 
?> 

閃存正在尋找flashMe類和類中的push方法,但我一直G當我運行它時,在我的Flash文件中設置空變量,這個代碼有什麼問題嗎?

Thanx提前!

回答

2

你的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; 
    } 
} 
?> 

這個文件應該被保存爲「HelloWorld」的匹配「類的HelloWorld」你在php文件命名(你這樣做部分正確與FlashMe)。

在文檔中的閃片(以動作)的示例文件是在這裏:

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也很新,但我發現the docs非常有用。如果你需要更多的課程幫助,你可以在PHP docs page找到更多信息。

0

你錯過了括號new flashMe

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

+0

Btw,如果它是空的,不需要__construct()。 – bPizzi 2010-07-09 14:10:53

+0

酷,thanx會放棄它。但是有可能實現我想要的嗎?因爲我沒有將變量發送到amf php並讓flash收到它。 – Odyss3us 2010-07-10 10:43:52