4 Replies Latest reply on May 7, 2007 4:40 PM by chris.huston.t10

    HTTP Problems

    solomonmine
      I am a total newbie to Flex and i am trying to create a simple chart
      the populates from a database, I am pulling the data from the DB
      using PHP script. The scrip works fine. the problem i am having is
      when i try to assign the value to a variable the whole page come back
      as as blank.

      public var leaveused:Number =
      leavedetails.lastResult.leaveinfo.leave.leavestdate;

      I know this is the problem because when i use static values the chart
      is displayed. I can assign the value above to a text.text and it gets
      displayed fine.

      Guys please help as i was dumb enough to try to do something i have
      never done b4 as a final uni project.

      Chimera
        • 1. Re: HTTP Problems
          peterent Level 2
          If your result format is XML, then try this:

          public var leaveused:Number =
          Number(leavedetails.lastResult.leaveinfo.leave.leavestdate );

          XML is strictly a text format, so leave.leavestdate might be "1234" which is the string, not the number. Using the Number operator will parse the string into its numeric equivalent.

          Most likely if you were to look at leaveused in the debugger or with a trace statement it would be NaN which means "not a number".
          • 2. Re: HTTP Problems
            solomonmine Level 1
            Tried that did not work. I must be missing something stupidly simple
            • 3. Re: HTTP Problems
              solomonmine Level 1
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="488" height="300">
              <mx:Script>
              <![CDATA[
              import mx.rpc.events.ResultEvent;
              import mx.controls.Text;
              import mx.controls.Alert;
              import mx.rpc.events.FaultEvent;


              [Bindable]
              public var selectedItem:Object;
              public var emptytext:String = new String();

              private function loginchk(e:ResultEvent):void
              {
              var resultcheck:Number= Number(loginscript.lastResult.staff.employeeid);
              if(resultcheck < 1)
              {
              Alert.show("Login Error! Please check password");
              }
              else
              {
              Alert.show("Login Successful!");
              }
              }
              ]]>
              </mx:Script>
              <mx:HTTPService id="loginscript" url=" http://server/hrmanager-php/phpapp/loginscript.php"
              method="GET" useProxy="false" fault="Alert.show(event.fault.faultString, 'Error')"
              result="loginchk(event)">
              <mx:request xmlns="">
              <shortname>
              {shortname.selectedItem}
              </shortname>
              <password>
              {mypassword.text}
              </password>
              </mx:request>
              </mx:HTTPService>

              This is the code, could someone tell me what i am doing wrong here that is giving me a NaN
              • 4. HTTP Problems
                chris.huston.t10 Level 3
                Try this for your function and run in debug mode to check what the actual value being returned is. You can see the result displayed in the Flex console window.

                private function loginchk(e:ResultEvent):void
                {
                var resultcheck:Number= Number(e.result.staff.employeeid);
                trace(e.result.staff.employeeid);
                if(resultcheck < 1)
                {
                Alert.show("Login Error! Please check password");
                }
                else
                {
                Alert.show("Login Successful!");
                }
                }

                Vygo