1 Reply Latest reply on Nov 19, 2007 11:15 PM by jono.r

    Noob alert - scope issue in functon?

    jono.r
      Hi very early days for me in Flex (no Java either!).

      I have a function getting data from a webservice which works fine. However, Id like to put portions of the result into a public variable. I seem to be doing it in the wrong place, but I'm not sure how to do it corrrectly. The line that trips me up in the following code is "userName=SessionMgr.sessionLogin.lastResult.getItemAt(0).first_name". The error indictates that lastresult is null.
      BTW, I can get the relevant items from lastResult to display in a TextArea OK.
      TIA :-)

      <mx:Script>
      <![CDATA[
      import mx.states.State;
      public var userName:String
      private function clickHandler(event:MouseEvent):void {
      switch (currentState)
      {case "loggedIn":
      currentState='';
      codeEntry.text = '';
      passwordEntry.text = '';
      break;
      default:
      SessionMgr.sessionLogin.send(codeEntry.text,passwordEntry.text)
      userName=SessionMgr.sessionLogin.lastResult.getItemAt(0).first_name
      currentState='loggedIn'
      break;
      }
      }
      ]]>
      </mx:Script> Text