<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flash Remoting: Error-proofing the Connection class</title>
	<atom:link href="http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/</link>
	<description></description>
	<lastBuildDate>Sun, 28 Feb 2010 15:02:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-26717</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 24 Sep 2009 00:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-26717</guid>
		<description>here is my solution, inspired by the original post and Ezequiel&#039;s addition.
(Tested in CS4, using AS2)

First create a class in a separate AS file, to extend the Connection:
import mx.remoting.Connection;
import mx.controls.Alert;
class ServiceConnection extends Connection {	
    function onStatus(p_status:Object):Void {
        if (p_status == undefined) {
            //trace(&quot;SC: The host cannot be reached&quot;);
            var al = Alert.show(
                &quot;Sorry a communications error has occurred.\n\nPlease check your network and internet connection and then reload this page.&quot;,
                &quot;Network Error!&quot;
            );
            al.setSize(360, 200);
        } else {
            //trace(&quot;onStatus: &quot; + p_status.code); // never runs?
        }
    }
}

then any number of services can be created to use the same connection:
this.serviceConnection = new ServiceConnection();
this.serviceConnection.connect(gatewayUrl);

this.myService1 = new Service(null, null, &quot;HelloWorld&quot;, this.serviceConnection, new RelayResponder(this, &quot;myService1ResultHandler&quot;, &quot;anyServiceFault&quot;)
);

this.myService2 = new Service(null, null, &quot;HelloUniverse&quot;, this.serviceConnection, new RelayResponder(this, &quot;myService2ResultHandler&quot;, &quot;anyServiceFault&quot;)
);</description>
		<content:encoded><![CDATA[<p>here is my solution, inspired by the original post and Ezequiel&#8217;s addition.<br />
(Tested in CS4, using AS2)</p>
<p>First create a class in a separate AS file, to extend the Connection:<br />
import mx.remoting.Connection;<br />
import mx.controls.Alert;<br />
class ServiceConnection extends Connection {<br />
    function onStatus(p_status:Object):Void {<br />
        if (p_status == undefined) {<br />
            //trace(&#8220;SC: The host cannot be reached&#8221;);<br />
            var al = Alert.show(<br />
                &#8220;Sorry a communications error has occurred.\n\nPlease check your network and internet connection and then reload this page.&#8221;,<br />
                &#8220;Network Error!&#8221;<br />
            );<br />
            al.setSize(360, 200);<br />
        } else {<br />
            //trace(&#8220;onStatus: &#8221; + p_status.code); // never runs?<br />
        }<br />
    }<br />
}</p>
<p>then any number of services can be created to use the same connection:<br />
this.serviceConnection = new ServiceConnection();<br />
this.serviceConnection.connect(gatewayUrl);</p>
<p>this.myService1 = new Service(null, null, &#8220;HelloWorld&#8221;, this.serviceConnection, new RelayResponder(this, &#8220;myService1ResultHandler&#8221;, &#8220;anyServiceFault&#8221;)<br />
);</p>
<p>this.myService2 = new Service(null, null, &#8220;HelloUniverse&#8221;, this.serviceConnection, new RelayResponder(this, &#8220;myService2ResultHandler&#8221;, &#8220;anyServiceFault&#8221;)<br />
);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hairy</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-16523</link>
		<dc:creator>hairy</dc:creator>
		<pubDate>Mon, 24 Mar 2008 09:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-16523</guid>
		<description>ya rite but some times its not work yaar. Give me some more info</description>
		<content:encoded><![CDATA[<p>ya rite but some times its not work yaar. Give me some more info</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mammut</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-15959</link>
		<dc:creator>mammut</dc:creator>
		<pubDate>Thu, 21 Feb 2008 10:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-15959</guid>
		<description>Is there a similar solution in AS3 ?
Thanks</description>
		<content:encoded><![CDATA[<p>Is there a similar solution in AS3 ?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Digi</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-10876</link>
		<dc:creator>Digi</dc:creator>
		<pubDate>Wed, 15 Aug 2007 15:00:25 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-10876</guid>
		<description>For anyone who was attempting to use Ezequiel&#039;s method and wasn&#039;t successful, modify the following line:

var service:Service = new Service(null, null, â€˜HelloWorldâ€™, conn);

to become:

var service:Service = new Service(null, null, â€˜HelloWorldâ€™, conn, this);

That seemed to do the trick for me.</description>
		<content:encoded><![CDATA[<p>For anyone who was attempting to use Ezequiel&#8217;s method and wasn&#8217;t successful, modify the following line:</p>
<p>var service:Service = new Service(null, null, â€˜HelloWorldâ€™, conn);</p>
<p>to become:</p>
<p>var service:Service = new Service(null, null, â€˜HelloWorldâ€™, conn, this);</p>
<p>That seemed to do the trick for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mecanography</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-4619</link>
		<dc:creator>mecanography</dc:creator>
		<pubDate>Mon, 19 Mar 2007 15:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-4619</guid>
		<description>@Bernardo_Kuri

try to publish for Flash 7 to see if it fix the type mismatch error. If so when publishing for Flash 8 define service like this :
[code]
var service:Service = new mx.remoting.Service(gatewayUrl, null, &#039;HelloWorld&#039;); 
[/code]
Seems AS2 in Flash8 doesn&#039;t understand well &#039;new Service&#039; it needs &#039;new mx.remoting.Service&#039; for not issuing a type error... I eventually ran amok before seeing this page : http://yawoong.com/board/view.php?id=tutorial_kidari70&amp;no=127</description>
		<content:encoded><![CDATA[<p>@Bernardo_Kuri</p>
<p>try to publish for Flash 7 to see if it fix the type mismatch error. If so when publishing for Flash 8 define service like this :<br />
[code]<br />
var service:Service = new mx.remoting.Service(gatewayUrl, null, 'HelloWorld');<br />
[/code]<br />
Seems AS2 in Flash8 doesn&#8217;t understand well &#8216;new Service&#8217; it needs &#8216;new mx.remoting.Service&#8217; for not issuing a type error&#8230; I eventually ran amok before seeing this page : <a href="http://yawoong.com/board/view.php?id=tutorial_kidari70&amp;no=127" rel="nofollow">http://yawoong.com/board/view.php?id=tutorial_kidari70&amp;no=127</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: enrique vamp</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-4599</link>
		<dc:creator>enrique vamp</dc:creator>
		<pubDate>Mon, 19 Mar 2007 06:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-4599</guid>
		<description>If any one change the gatewayURL to mine (amfphp 1.2) and replace your service.whatever call so it works with my setup/function.</description>
		<content:encoded><![CDATA[<p>If any one change the gatewayURL to mine (amfphp 1.2) and replace your service.whatever call so it works with my setup/function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-2717</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Fri, 02 Feb 2007 19:59:16 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-2717</guid>
		<description>Awesome code Ezequiel! I like your solution rather than patching core classes. Thanks a lot!

Damn it, it&#039;s so easy actually.. and I was looking for such a long time for a solution!

Thanks guys.</description>
		<content:encoded><![CDATA[<p>Awesome code Ezequiel! I like your solution rather than patching core classes. Thanks a lot!</p>
<p>Damn it, it&#8217;s so easy actually.. and I was looking for such a long time for a solution!</p>
<p>Thanks guys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ezequiel</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-988</link>
		<dc:creator>Ezequiel</dc:creator>
		<pubDate>Sat, 23 Dec 2006 16:37:19 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-988</guid>
		<description>If you want avoid patching, you can make use of the connection argument passed to the Service class. For example:

var gatewayUrl:String = &quot;http://dev.caleb.org/amfphp/gateway.php&quot;
var conn:Connection = new Connection();
conn.onStatus = function( info ):Void
{
    if (info == undefined) {
        trace(&quot;The host can&#039;t be reached&quot;);
    } else {
        trace(&quot;onStatus: &quot; + info.code);
    }
}
conn.connect(gatewayUrl);
var service:Service = new Service(null, null, &#039;HelloWorld&#039;, conn);
var pc:PendingCall = service.say(&quot;Hello world!&quot;);
pc.responder = new RelayResponder(this, &quot;handleResult&quot;, &quot;handleError&quot;);
function handleResult(re:ResultEvent)
{
    trace(&#039;The result is: &#039; + re.result);
}
function handleError(fe:FaultEvent)
{
    trace(&#039;There has been an error&#039;);
}

Hope that helps.</description>
		<content:encoded><![CDATA[<p>If you want avoid patching, you can make use of the connection argument passed to the Service class. For example:</p>
<p>var gatewayUrl:String = &#8220;http://dev.caleb.org/amfphp/gateway.php&#8221;<br />
var conn:Connection = new Connection();<br />
conn.onStatus = function( info ):Void<br />
{<br />
    if (info == undefined) {<br />
        trace(&#8220;The host can&#8217;t be reached&#8221;);<br />
    } else {<br />
        trace(&#8220;onStatus: &#8221; + info.code);<br />
    }<br />
}<br />
conn.connect(gatewayUrl);<br />
var service:Service = new Service(null, null, &#8216;HelloWorld&#8217;, conn);<br />
var pc:PendingCall = service.say(&#8220;Hello world!&#8221;);<br />
pc.responder = new RelayResponder(this, &#8220;handleResult&#8221;, &#8220;handleError&#8221;);<br />
function handleResult(re:ResultEvent)<br />
{<br />
    trace(&#8216;The result is: &#8216; + re.result);<br />
}<br />
function handleError(fe:FaultEvent)<br />
{<br />
    trace(&#8216;There has been an error&#8217;);<br />
}</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernardo Kuri</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-412</link>
		<dc:creator>Bernardo Kuri</dc:creator>
		<pubDate>Sat, 02 Dec 2006 07:04:57 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-412</guid>
		<description>Hello Caleb,

Thanks a lot for sharing this code! I wouldn&#039;t have known about this issue otherwise.

Unfortunately, I just can&#039;t get it to work properly. Adding &#039;this&#039; as the last parameter for the service call will return a &#039;type mismatch&#039; compiler error, and simply removing it (or adding a valid responder param) doesn&#039;t do anything at all (as in no RPC code gets executed). Changing to a valid gateway path does get things rolling again, although onStatus() never gets called either way.

I am using version 9.0r28 of the flash player. My code differs slightly from yours in that I&#039;m adding a logger as a second parameter to my service call (in case this makes any difference).

Thanks for your time, and good luck on your business trip!</description>
		<content:encoded><![CDATA[<p>Hello Caleb,</p>
<p>Thanks a lot for sharing this code! I wouldn&#8217;t have known about this issue otherwise.</p>
<p>Unfortunately, I just can&#8217;t get it to work properly. Adding &#8216;this&#8217; as the last parameter for the service call will return a &#8216;type mismatch&#8217; compiler error, and simply removing it (or adding a valid responder param) doesn&#8217;t do anything at all (as in no RPC code gets executed). Changing to a valid gateway path does get things rolling again, although onStatus() never gets called either way.</p>
<p>I am using version 9.0r28 of the flash player. My code differs slightly from yours in that I&#8217;m adding a logger as a second parameter to my service call (in case this makes any difference).</p>
<p>Thanks for your time, and good luck on your business trip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kay</title>
		<link>http://caleb.org/blog/uncategorized/flash-remoting-error-proofing-the-connection-class/comment-page-1/#comment-284</link>
		<dc:creator>Kay</dc:creator>
		<pubDate>Wed, 15 Nov 2006 17:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://caleb.org/blog/?p=24#comment-284</guid>
		<description>I tried your example and could not get it to fire any error. I even downloaded your files. And used those and still nothing. I modified both class files. I&#039;m using flash 8 and publishing to 8 as well.</description>
		<content:encoded><![CDATA[<p>I tried your example and could not get it to fire any error. I even downloaded your files. And used those and still nothing. I modified both class files. I&#8217;m using flash 8 and publishing to 8 as well.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
