# \[AS2\]Flash gateway (with AMFPHP)!

**URL:** <https://forum.kirupa.com/t/as2-flash-gateway-with-amfphp/214116>\
**Category:** flash\
**Created:** [January 25, 2007, 6:08pm UTC](https://forum.kirupa.com/t/as2-flash-gateway-with-amfphp/214116 "2007-01-25T18:08:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [January 25, 2007, 6:08pm UTC](https://forum.kirupa.com/t/as2-flash-gateway-with-amfphp/214116/1 "2007-01-25T18:08:16Z")

</div>

Hello guys,

I have a question ( i search from 2 day with google to find a way), i have a class for remoting service for flash using amfphp! I have done every as wanted, but the want that i use 3 gateways, and to connect to the first one that works (is online), i have something like this my code:

```auto

	private var gatewayUrl_0:String = "http://server1/flashservices/gateway.php";
	private var gatewayUrl_1:String = "http://server2/flashservices/gateway.php";
	private var gatewayUrl_2:String = "http://server3/flashservices/gateway.php";
        private var tried:Number = 0;
	function getDatabase()
	{
		NetDebug.initialize();
		this.service = new Service(this.gatewayUrl_0, null, "getDatabase");
		this.doRead();
                this.tried++;	
	}
	
	function doRead()
	{		
		var pc:PendingCall = service.doRead();
		pc.responder = new RelayResponder(this, "handleDoRead", "handleRemotingError");
		this.xml.load("http://server/flashservices/services/cameraLink.xml");
	}
        function handleDoRead(re:ResultEvent)
        {
                 this.dataGrid.dataProvide = RecordSet(re.result);
        }
        function handleRemotingError(er:FaultEvent)
        {
              if(this.tried==1)
                 {
                       this.service = new Service(this.gatewayUrl_1, null, "getDatabase");
		this.doRead();
                  }
               else if(this.tried==2)
                  {
                       this.service = new Service(this.gatewayUrl_2, null, "getDatabase");
 		this.doRead();
                  }
                else if(this.tried==3)
                {
                trace("NO GATEWAY WORKING");
          }

```

But this doesn’t work, can somebody help me?

Thank you in advance, btibia! :thumb2:
