8 Replies Latest reply on Jul 12, 2011 2:49 PM by code_away

    Actionscript variable that never changes later becomes null/empty

    code_away Level 1

      I've been trying literally for the last year to identify the source of the issue.

       

      I have a transactional SaaS Flex application where hundreds of records are entered daily. Every few days or so, I my PHP application catches an error where a Flex/Actionscript variable, CLIENT_ID which is passed via HTTP POST, becomes blank/null. But no where in the Flex application is the variable ever updated after its first assignment, so I'm baffled as to why it would later become blank/null. 

       

      [Bindable]

      public var CLIENT_TOKEN:String; //token to security purposes

      [Bindable]

      public var ROLE_CODE:String; //see variable roles

      [Bindable]

      public var CLIENT_ID:String;


       

      As I think about it, for CLIENT_ID, I really don't need the [Bindable] meta tag since the variable doesn't change once set (in fact, the same for the other variables).

       

      Any thoughts as to why a variable would - presumably after sometime - become null/blank? Could [Bindable] somehow "add" to the issue if the issue were say memory leak related?

       

      Thx,

      Code_away

        • 1. Re: Actionscript variable that never changes later becomes null/empty
          Flex harUI Adobe Employee

          I would replace with your own get/set pair and set a breakpoint

          in the setter.

          • 2. Re: Actionscript variable that never changes later becomes null/empty
            code_away Level 1

            I guess the bigger question is what could cause a variable to become null/empty for seemingly no reason?

             

            Does anyone know of certain bugs/limitations that would cause this to happen?

             

            I certainly see excluding bindable would be a "better practice" since CLIENT_ID and the other variables never change. CLIENT_ID is used to identify the SaaS client/user who is logged in, so the app would never change this value for the session.

            • 3. Re: Actionscript variable that never changes later becomes null/empty
              UbuntuPenguin Level 4

              Can you reproduce the error at will ?  If so, do like HarUI said and replace the variable with getters and setters (Bindable or not is up to you) then place a break point at the setter.  When the breakpoint is hit, just continue to step through the code until you find out which function was calling it.

              • 4. Re: Actionscript variable that never changes later becomes null/empty
                Flex harUI Adobe Employee

                Even if you can't repro at will, if you throw an error when null is assigned

                and are running a debugger player, you can get call stack info and help

                diagnose the cause as well.

                • 5. Re: Actionscript variable that never changes later becomes null/empty
                  code_away Level 1

                  Yeah, I'm unable to reproduce the issue. At first, I thought maybe it had to do with the session expiring and or similar and the user interacting with the app.

                   

                  I would hate to create and deploy a build just to diagnose this problem, but it seems there are no other thoughts and this is my best shot. In addition, I would have to ask the user to email it to me unless I write code extra code to send back to me via an HTTP post call..oh boy..

                   

                  CLIENT_ID is only assigned once. Below is how I would utilize it for the HTTP POST call back to the server...

                   

                  <mx:HTTPService ...>
                     <mx:request xmlns="">
                         <ClientID>{CLIENT_ID}</ClientID>
                          . . .
                     </mx:request>
                  </mx:HTTPService>

                  • 6. Re: Actionscript variable that never changes later becomes null/empty
                    code_away Level 1

                    OK. I removed [Bindable] meta tag prior to CLIENT_ID, but Flex Builder(3.0) throws a warning 'Data binding will not be able to detect assignments to "CLIENT_ID" for the below:

                     

                    <mx:HTTPService ...>
                       <mx:request xmlns="">
                           <ClientID>{CLIENT_ID}</ClientID>
                            . . .
                       </mx:request>
                    </mx:HTTPService>

                     

                     

                    However, elsewhere I have

                     

                    <mx:HTTPService ...>
                       <mx:request xmlns="">
                           <ClientID>{Application.application.CLIENT_ID}</ClientID>
                            . . .
                       </mx:request>
                    </mx:HTTPService>

                    Am I supposed to be use "Application.application." to "properly" access my non-bindable, local variables?


                     

                    • 7. Re: Actionscript variable that never changes later becomes null/empty
                      Flex harUI Adobe Employee

                      If you are going to bind to CLIENT_ID, you will need to use

                      [Bindable("propertyChange")] metadata and dispatch the appropriate event in

                      the setter.  You can use -keep to see how the setter was generated when you

                      used just plain

                      • 8. Re: Actionscript variable that never changes later becomes null/empty
                        code_away Level 1

                        After 14 months not being able to solve this issue, I'm finally sure I've identified it.

                         

                        I recently made a change to my flex app, and I wanted to make sure when folks who logged in got the latest (non-cached) version. So, I made the following revision to AC_FL_RunContent that loads the SWF file.

                         

                        AC_FL_RunContent(
                        "src", "<?php echo base_url();?>FlexApp?nocache="+(new Date()).getTime(),
                        "width", "100%",
                        "height", "100%",
                        "align", "middle",
                        "id", "FlexApp",
                        "quality", "high",
                        "bgcolor", "#869ca7",
                        "name", "FlexApp",
                        "allowScriptAccess","sameDomain",
                        "type", "application/x-shockwave-flash",
                        "pluginspage", "http://www.adobe.com/go/getflashplayer"
                        );

                         

                        After of few days, I noticed the error stopped appearing which otherwise show up at least every 2 or 3 days. It's been 6+ weeks now, and still no error.

                         

                        So I have concluded that somehow, the browser is caching the SWF file and not performing the POST calls to set the values for the variables (CLIENT_ID etc). Maybe the user is performed quickly some funky browser actions.

                         

                        Ideally I want caching so as to speedup login performance, but I may need to forgo caching.