Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
To apanhando muito... com o simples exemplo hello world do amf.... vamos lá... o servidor apache e o php ja estao instalados e funcionando....
como no exemploo deste site http://www.leonardofranca.com.br/?p=22, fui fazer o amfphp funcionar.
Criei o arquivo php com nome de teste.php
< ?phpclass teste{function teste(){$this->methodTable = array("ola" => array("description" => "testando o AMFPHP","access" => "remote", // available values are private, public, remote"arguments" => array ("msg")));} function ola($msg){return $msg;}}?>
coloquei ele dentro da pasta services do amfphp, que no meu caso está em
C:\apache\Apache\htdocs\flashservices\services
fui no flash, nem fucei nada, apenas apertei F9 e digitei o codigo conforme o site.
import mx.remoting.Service;import mx.services.Log;import mx.rpc.RelayResponder;import mx.rpc.FaultEvent;import mx.remoting.DataGlue;import mx.rpc.ResultEvent;import mx.remoting.PendingCall;import mx.remoting.RecordSet;//troque localhost pelo endereço do seu servidor webvar conexao = new Service("http://localhost/flashservices/gateway.php", new Log(), "teste", null, null);var pcs:PendingCall = conexao.ola("Ola Flash Remoting!!!");pcs.responder = new RelayResponder(this, "ola_Result", "ola_Fault");function ola_Result(res:ResultEvent) {trace(res.result);}function ola_Fault(fault:FaultEvent) {trace(fault.fault.faultstring);}
quando rodo com CTRL + ENTER no trace do flash ele me mostra:
7/1 9:0:19 [INFO] : Invoking ola on testeThe file {teste.php} exists and was included correctly but a class by that name could not be found in that file. Perhaps the class is misnamed.
Não funciona nem na empresa nem em casa....
Alguem sabe o q pode estar acontecendo ??
Obrigado.
ah, esse erro é devido a antiga versão do blog que colocava "<? php" ao inves de "<?php"mas dei uma evoluida nesse aspecto, veja esse artigohttp://www.leonardofranca.com.br/index.php...gn-patterns/pt/
>
Bom, um colega meu, o Will, conseguiu me ajudar.... ficou assim...teste.php
<?phpclass teste{function teste(){$this->methodTable = array("getTeste" => array("description" => "testando o AMFPHP","access" => "remote", // available values are private, public, remote"arguments" => array ("msg"),"returntype" => "recordSet" //indica que retornará um recordset));} function getTeste($msg){return $msg;}}?>asimport mx.remoting.Service;import mx.services.Log;import mx.rpc.RelayResponder;import mx.rpc.FaultEvent;import mx.remoting.DataGlue;import mx.rpc.ResultEvent;import mx.remoting.PendingCall;import mx.remoting.RecordSet;//troque localhost pelo endereço do seu servidor webvar conexao = new Service("[http://localhost/flashservices/gateway.php",](http://localhost/flashservices/gateway.php) new Log(), "teste", null, null);var pcs:PendingCall = conexao.getTeste("Ola Flash Remoting!!!");pcs.responder = new RelayResponder(this, "teste_Result", "teste_Fault");function teste_Result(res:ResultEvent) {trace(res.result);}function teste_Fault(fault:FaultEvent) {trace(fault.fault.faultstring);}
Bom, um colega meu, o Will, conseguiu me ajudar.... ficou assim...
teste.php
as
import mx.remoting.Service;import mx.services.Log;import mx.rpc.RelayResponder;import mx.rpc.FaultEvent;import mx.remoting.DataGlue;import mx.rpc.ResultEvent;import mx.remoting.PendingCall;import mx.remoting.RecordSet;//troque localhost pelo endereço do seu servidor webvar conexao = new Service("http://localhost/flashservices/gateway.php", new Log(), "teste", null, null);var pcs:PendingCall = conexao.getTeste("Ola Flash Remoting!!!");pcs.responder = new RelayResponder(this, "teste_Result", "teste_Fault");function teste_Result(res:ResultEvent) {trace(res.result);}function teste_Fault(fault:FaultEvent) {trace(fault.fault.faultstring);}