1 Reply Latest reply on Aug 26, 2009 10:10 PM by _Natasha_

    null variables in actionScript via .mxml (flex 3) calls.

    Luke Immes

      Problem with invoking action script, during .mxml call.

      This larger example works, with accounts variable returning .xml, as expected.

      BUT, if I want to access .xml right after .send() command, debugger says null for this variable.

      I have code for a customer, where .xml is returned, I want to do some checking in action Script.

      Value shows null.

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"

        applicationComplete="setup()">

      <mx:Script>

        <![CDATA[              

          private const CONTEXT_URL:String = "http://localhost:3001";

       

          [Bindable] private var accounts:XML;

          [Bindable] private var positions:XML;

          [Bindable] private var movements:XML;

       

          private function setup():void {

            accountsIndex.send();

          }

      ...

      Break point set a accountsIndex.send(), then step over; accounts is null.

       

       

       

      Another example:

      ...

        INVOKED BY id=loginButton, LOGIN

      private function loginServer(event:Event):void {

              clicked = true;

      try {

      loginService.send({user_session:{login:uname.text, password:pw.text}});

      }

      catch (error:ArgumentError) {}

      catch (error:MemoryError) {}

      catch (error:SecurityError) {}

      catch (error:TypeError) {}

      catch (error:Error) {}

      }

       

      userSession is null if breakpoint set at loginSession, then step over.

       

      So, its not a server problem not returning data, because in both cases, these (.mxml) applications work with their respective values set.

      Now, if I invoke a 2nd button, CONTINUE, then userSession is notNull. Fine.

      Hunches: do validation in mxml, when the LOGIN button is pressed- in other words, JUST  a single button with validation inside of it.

       

      Of course, in the accounts.send problem, it is called via applicationComplete, not a button.

      I am more interested in the LOGIN validation BUTTON solution.

      Thanks.