PDA

View Full Version : [AS3] What am I doing wrong? (Remoting)


iceflyin
07-24-2007, 11:19 AM
Straight out of the tutorial: http://www.oscartrelles.com/archives/as3_flash_remoting_example

The error I get is 'call to a possibly undefined RemotingTest. I have tried everthing... remoting.RemotingTest(); public.RemotingTest(); Help...


//Code in SWF

import remoting.remoting;
import remoting.remotingService;
RemotingTest();

Both of these are in the folder 'remoting':

//Inside remoting.as
package {
import flash.net.Responder;
public class RemotingTest {
private var rs:RemotingService;
function RemotingTest() {
init();
}
private function init() {
rs=new RemotingService("http://your.domain.com/amfphp/gateway.php");
var responder:Responder=new Responder(onResult,onFault);
var params:Object=new Object ;
params.arg1="something";
params.arg2="2";
rs.call("Class.method",responder,params);
}
private function onResult(result:Object):void {
trace(result);
}
private function onFault(fault:Object):void {
trace(fault);
}
}
}



//Inside remotingServices.as
package {
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
public class RemotingService extends NetConnection {
function RemotingService(url:String) {
// Set AMF version for AMFPHP
objectEncoding=ObjectEncoding.AMF0;
// Connect to gateway
connect(url);
}
}
}

iceflyin
07-24-2007, 03:15 PM
Could someone tell me how the heck to use code in CS3, before I tear my hair out and go back to MX...