Skip to main content
Participant
March 11, 2011
Question

AMF connection working on browser, not in stand alone player

  • March 11, 2011
  • 1 reply
  • 473 views

Greetings,

I'm trying to communicate my SWF file with PHP using Zend_Amf. I compile the flash side using Flex SDK 4.

Whenever I try to run the swf using the stand alone player (the projector), I always get a NetConnection.Call.BadVersion event. However, when running exactly the same file thorught the player of the browser (even not thoguht a server, just using the file:// kind of address), everything works OK, so I know my code is not completely wrong.

I thought this could be related with the security sandbox. However, I added the folder where my swf file is to the global trusted folder; and actually made sure that Security.sandboxType returns "localTrusted". How ever, that didn't fix anything.

So I'm out of ideas. Any suggestion on where to look next?

This topic has been closed for replies.

1 reply

Participant
March 14, 2011

Here's my code, in case its needed (it's a pretty straightforward hello world example):

PHP SIDE:

$a = new Amf_Model_Test();    
$server = new Zend_Amf_Server();    
$server->setClass('Amf_Model_Test');    
echo $server->handle();
class Amf_Model_Test
{  
/**   
* return string                  
*/  
public function greet()  
  {    
    return "hello";  
  }
}
AS SIDE:

public class main extends Sprite  
{    
private var _resp: Responder;    
private var _nc: NetConnection;    
private var tf: TextField;    
private var _gateway: String;    

public function main()    
{                
tf = new TextField();      
tf.width = 500;      
tf.border = true;      
tf.borderColor = 0x0000FF;      
addChild(tf);       _gateway = 'http://cms.loc/amf';      
_resp = new Responder(onResult, onFault);      
_nc = new NetConnection();      
_nc.connect(_gateway);            
_nc.client = this;      
_nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);            
_nc.call("Amf_Model_Test.greet", _resp);          
}    

private function onNetStatus(event: NetStatusEvent): void    
{          
trace(event.info['code']);          

tf.text = "Status = "+event.info['code'];
}    

private function onFault(result: Object): void    
{      
tf.text = "Fault = " + String(result);    
}    

private function onResult(result: Object): void
{       tf.text = "Result = " + String(result);    
}  
}
}

In my browser, I get "Result = hello", as expected. In the stand alone player (which is exactly the same version) I get "Status = NetConnection.Call.BadVersion".