7 Replies Latest reply on Aug 28, 2006 7:14 AM by Graeme Harker

    Binding Static Variables

    dimival Level 1
      I have some static variables in a class which are obviously values that never change. Then in my mxml i bind these values to some components so they can access those static values, the problem is that it gives me the following warning:

      "Data binding will not be able to detect assignments to..."

      How do i get rid of those warnings? Obviously using the Bindable metadata doesn't work because they are static variables, i only need my components to be able to access those values without those warnings, does anyone know how???

      Thanks
      Diego
        • 1. Re: Binding Static Variables
          inlineblue Level 1
          Binding to static varaibles should not be a problem. You might get a compiler warning, but they're just warnings. How're you doing the binding?
          • 2. Re: Binding Static Variables
            jpwrunyan Level 1
            I had the same issue. In Flex 1.5 there were never any warnings, in 2.0 they throw a warning. The application does work just fine, though. Maybe it's more an issue with Flex Builder and bogus (sort-of) errors.
            • 3. Re: Binding Static Variables
              dimival Level 1
              I am doing the binding like this:

              <ns2:Boton ctrl="{ctrl}" label="Listar" tag="{Controller.LIST}" click="ctrl.actionList(event)"/>

              The Controller class has many static variables, in this example LIST. As you said, it is just a warning but when i deploy my application on a web server, it throws all these warnings in my browser, which looks terrible. I can't show the application to my client because those warnings are showing in the browser. That's why i want to get rid of them. Any ideas?
              • 4. Re: Binding Static Variables
                inlineblue Level 1
                Appearing in your browser? How? They're supposed to be trace messages that go to the debug console. Where in the browser are they appearing?
                • 5. Re: Binding Static Variables
                  inlineblue Level 1
                  quote:

                  Originally posted by: jpwrunyan
                  I had the same issue. In Flex 1.5 there were never any warnings, in 2.0 they throw a warning. The application does work just fine, though. Maybe it's more an issue with Flex Builder and bogus (sort-of) errors.

                  Just FYI, they're not bogus warnings. Because static variables cannot be declared [Bindable], Flex will not be able to detect assignments to them, so any changes you make at runtime won't trigger a binding. However, if you're not going to make changes to the variables, then there's no problem because the initial value is always picked up when the app first starts.
                  • 6. Re: Binding Static Variables
                    dimival Level 1
                    quote:

                    Originally posted by: inlineblue
                    Appearing in your browser? How? They're supposed to be trace messages that go to the debug console. Where in the browser are they appearing?


                    Nope, they appear in the browser window when i deploy my application. I can send you a snapshot so you can see it for yourself but i will need your email or something.
                    • 7. Re: Binding Static Variables
                      Graeme Harker
                      A var that's declared "static" doesn't stay the same necessarily.

                      For example, Cairngorm's whole data "model" in V1.5 is implemented as a set of static variables of a class that's never instantiated and the "view" is bound to those static variables. Needless to say that doesn't work in V2.

                      Out of interest, why can't static variables be declared [Bindable] in V2?