3 Replies Latest reply on Feb 8, 2012 1:25 AM by Fatlog

    Setting Value of Static Const




      I want to set the value of a static const to a localised string...


      public static const DEFAULT_PROPERTY_NAME:String =


              'strings', 'myVar');


      But it is always null...

        • 1. Re: Setting Value of Static Const
          oldMster Level 3

          The words static and constant mean exactly that.  What you want is a variable (probably protected).  static constants have to be known at compile time.


          • 2. Re: Setting Value of Static Const
            GordonSmith Level 4

            If this compiles, then the problem is that the ResourceManager is loaded with resources AFTER the static initializatino of this class occurs. You'll probalby have the same problem if you make it a static var and initialize it in the declaration of the var. However, you could make it a static var (or maybe even a static const) and initialize in the constructor of the first instance, with code like


            public MyClass()


                if (DEFAULT_PROPERTY_NAME == null)

                    DEFAULT_PROPERTY_NAME = ResourceManager.getInstance().getString('strings', 'myVar');



            By the time you are constructing instances, the ResourceManager should be loaded with resources.


            Gordon Smith, Adobe

            1 person found this helpful
            • 3. Re: Setting Value of Static Const
              Fatlog Level 1

              This helps. I was wondering because it does compile.

              I'll give your suggestion a go