3 Replies Latest reply on Sep 9, 2009 10:51 AM by Flex harUI

    Weird 50:50 success/fail

    Matt Le Fevre Level 4

      a very weird issue that has haunted me for several days now, the thing that confuses me the most is the way the code will run perfectly fine on attempt 1, fail on attempt 2, succeed on attempt 3, fail on attempt 4 etc...


      the code isn't being changed each time, it just seems to be choosing to fail half the time.



      Basically i am sending an HTTP service request through flex to retrieve cookie information, to fill in a loginbox (If someones selected the 'remember me button, a cookie is created etc...)


      The cookie is always set, i can read it absolutely fine using a quick basic php script, the application can read it absolutely fine half the time.


      so the request is sent off:

      <mx:HTTPService id="getcookie" result="getCookieInfo(event)" showBusyCursor="true" method="POST" url="http://localhost/checkCookie.php"/>


      goes to the php file:


      $mysql = mysql_connect('localhost', 'root', '') or die(mysql_error());
      $username = $_COOKIE["user"];
      $query = mysql_query("SELECT password FROM users WHERE username = '$username'");
      $result = mysql_result($query, 0);
      $echo "<cookie><username>".$username."</username><password>".$result."</password></cookie>";



      annnnnnnd then it returns to the function getCookieinfo(event),



      private function getCookieInfo(evt:ResultEvent):void
              if (evt.result.cookie.password != null)
                  passwordBox.text = evt.result.cookie.password



      then! Like i said, 50% of the time it will read the cookie, get the information and display it correctly.


      the other 50% of the time.... it highlights "evt.result.cookie.password" and returns the error:


      TypeError: Error #1010: A term is undefined and has no properties.
          at XUI_Login/getCookieInfo()[C:\Documents and Settings\Matt\My Documents\Flex Builder 3\XUI Builder 3 WEB\src\Login_Script.as:115]
          at XUI_Login/__getcookie_result()[C:\Documents and Settings\Matt\My Documents\Flex Builder 3\XUI Builder 3 WEB\src\Login.mxml:133]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\3.0.x\frameworks\pro jects\rpc\src\mx\rpc\http\mxml\HTTPService.as:275]
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\3.0.x\frameworks\projec ts\rpc\src\mx\rpc\AbstractInvoker.as:191]
          at mx.rpc::Responder/result()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:4 1]
          at mx.rpc::AsyncRequest/acknowledge()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AsyncR equest.as:74]
          at DirectHTTPMessageResponder/completeHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\ messaging\channels\DirectHTTPChannel.as:381]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/onComplete()




      Any advice on how to resolve this would be most helpful as i've been tearing my hair out for some time now! I hope its not something simple...