/**
 * This file generated by AMFPHP 1.0
 * You can get AMFPHP to generate code customized to your preferences
 * By modifying the /browser/templates/as2.tpl file
 */

import mx.remoting.*;
import mx.rpc.*;
import mx.utils.Delegate;
import mx.remoting.debug.NetDebug;

class <?php echo $info['package'] . $info['class'] ?>

{
	//Change the gateway URL as needed
	private var gatewayUrl:String = "<?php echo $info['gatewayUrl']; ?>";
	private var service:Service;

	function <?php echo $info['class'] ?>(<?php if($info['auth']){ echo ("user, pass"); } ?>)
	{
		NetDebug.initialize();
		this.service = new Service(this.gatewayUrl, null, "<?php echo $info['package'] . $info['class'] ?>");
		<?php if($info['auth']){ ?>this.service.connection.setCredentials(user, pass);<?php } ?>

	}
	
	<?php foreach($info['methods'] as $key => $method) { ?>
	
	//<?php echo $method['description']?>
	
	function <?php echo $method['methodName']?>(<?php echo $method['typedArgs']?>)
	{
		var pc:PendingCall = service.<?php echo $method['methodName']?>(<?php echo $method['args']?>);
		pc.responder = new RelayResponder(this, "handle<?php echo ucfirst($method['methodName'])?>", "handleRemotingError");
	}
	<?php } ?>
	
	<?php foreach($info['methods'] as $key => $method) { ?>
	
	function handle<?php echo ucfirst($method['methodName'])?>(re:ResultEvent)
	{
		//Implement custom callback code
	}
	<?php } ?>

	function handleRemotingError( fault:FaultEvent ):Void 
	{
		NetDebug.trace({level:"None", message:"Error: " + fault.fault.faultstring });
	}
}
