Working with exceptions with Adobe Flex and Zend AMF

Some programming languages have the capability of working with exceptions such as PHP, ActionScript 3.0, Java, C # etc.. It is a resource that if properly used, it is powerful and help prevent future headaches for your system. An exception is nothing more than the possibility of treating an error without necessarily stop completely your program.
Support for exceptions was added in PHP since version 5, and may be using in conjunction with Adobe Flex, this case will use the Zend AMF, an implementation of the AMF protocol for working together with the Flash Platform and its server- side running PHP as part of ZendFramework.
It is considered a best practice you create your exception class extending the class Zend_Exception.

In Flex we usually call the method using the RemoteObject class.
protected function application1_creationCompleteHandler(event:FlexEvent):void
ro = new RemoteObject();
ro.destination = “nao faz diferença nenhuma usando com Zend AMF”;
ro.endpoint = “http://localhost:81/ZendAmf/teste_exception.php”;
ro.source = “”;
ro.addEventListener(ResultEvent.RESULT, handlerResult);
ro.addEventListener(FaultEvent.FAULT, handlerFault);
Our attention will turn to the FaultEvent, he is responsible for catching exceptions coming from the server. Basically just need to show the user the faultString.
private function handlerFault(fault:FaultEvent):void
We have the following result:


Code completion:
Download PHP
Download Flex

Was this article helpful? feel free to make a donation and help keep the blog in the air
ActionScript 3.0, Flex, PHP, ZendAMF

1 comment

Leave a Reply