2 Replies Latest reply on Jan 14, 2010 9:35 AM by David Brannan

    Cannot access binded variable inside a resultEvent

    David Brannan

      Hello from Alaska - it was only -47 F this morning.

       

      I'm adding a flex multi-file uploader to my application and ran into a sticking point (going on 3 days now), and I hope someone with a kind heart and more IQ points than I was blessed with can help.

       

      In order to upload files to a CF uploader I am passing in two variables (jsessionID + myQuestionID).

       

      This all takes place in a function as follows:

      =======================================================

      // initUploader is called when account info loads

      public function getSessionInfoResult(event:ResultEvent):void{       

                 

      // Get jsessionid & questionid (final directory) for CF uploader

      myToken = roAccount.getSessionToken.lastResult;

      myQuestionID = questionsDG.selectedItem.QuestionID;

                 

      var postVariables:URLVariables = new URLVariables();

      postVariables.jsessionid = myToken;

      postVariables.questionid = myQuestionID;            

                 

      multiFileUpload = new MultiFileUpload(

                      filesDG,

                      browseBTN,

                      clearButton,

                      delButton,

                      upload_btn,

                      progressbar,

                      uploadDestination,

                      postVariables,

                      350000,

                      filesToFilter

                );

                 

      multiFileUpload.addEventListener(Event.COMPLETE,uploadsfinished);        

      }

      =======================================================

       

      I've set myQuestionID as a public binded variable at the top of my actionscript block as follow:

      [Bindable]

      public var myQuestionID:int;

       

      I can see myQuestionID elsewhere in my form, but not inside the getSessionInfoResult function.

       

      No matter how I try to bind it - private, public, create it's own function, it just won't show up in getSessionInfoResult.

       

      Any ideas out there would sure be appreciated.

        • 1. Re: Cannot access binded variable inside a resultEvent
          Gregory Lafrance Level 6

          This code shows it is visible within the result handler. Something else must be wrong with your code.

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="svc.send();">
            <mx:Script>
              <![CDATA[
                import mx.rpc.events.ResultEvent;
                [Bindable] public var myQuestionID:int;   
               
                public function getSessionInfoResult(event:ResultEvent):void{         
                  myQuestionID = 59355;
                }
              ]]>
            </mx:Script> 
            <mx:HTTPService id="svc" url="http://www.google.com" 
              result="getSessionInfoResult(event);" resultFormat="text"/>
            <mx:Text text="{myQuestionID}"/>
          </mx:Application>
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          1 person found this helpful
          • 2. Re: Cannot access binded variable inside a resultEvent
            David Brannan Level 1

            Hello Greg - thank you for taking a bit of your day to help.

             

            If I hard code myQuestionID = 59355; into the getSessionInfoResult it is visible (I did that for debuggin ensure my uploader works - and it does).

             

            However, if I try to bind a selected item from my grid inside getSessionInfoResult - like:

             

            myQuestionID =questionsDG.selectedItem.QuestionID;

             

            then it shows a value of null.

             

            I cannot get myQuestionID =questionsDG.selectedItem.QuestionID; to work anywhere between my action script tags, but it works fine in the form itself.

             

            Attached is updated code.