2 Replies Latest reply on Feb 16, 2010 3:37 PM by aarnott5050

    try catch not capturing error

    aarnott5050

      I am trying to create a simple xml socket connection and I want it to fail gracefully (not throw up a dialog on an error). For some reason, a dialog is still being thrown even though I have encolsed it in a try catch block. Here is my code:

       

      package
      {
          import flash.net.XMLSocket;
         
          public class SimpleConnection
          {
              private var xmlsock:XMLSocket;
             
              public function SimpleConnection()
              {               
              }
             
              public function connect():Boolean
              {
                  try {
                      xmlsock = new XMLSocket();
                      xmlsock.connect("127.0.0.1", 4444);
                  } catch (e:Error) {               
                      trace(e.getStackTrace());
                      return false;
                  }
                  return true;
              }
             
              public function disconnect():void
              {
                  xmlsock.close();
              }

       


          }
      }

       

       

      I am obviously pretty new to Actionscript and Flex, but I have a fairly extensive background with Java. I should note that this code works well so long as I have the server running.

       

      Thanks!