3 Replies Latest reply on Jul 13, 2007 5:33 AM by JKohn99

    Refferencing  ResourseBundle Externaly at Runtime

    levancho Level 3
      Currently I use resourseBundle following way
      private static var rb:ResourceBundle;

      but it gets embedded inside compiled swf,
      what I am looking for is the way to reference properties file in flex application as external resource at runtime so I can change some values in properties file and dont have to recompile the flex project.
      How would I achived that?
        • 1. Refferencing  ResourseBundle Externaly at Runtime
          cheftimo Level 2

          Here is an example that shows something similar to what you are talking about:
          I played with this for months, but ran into problems because I couldn’t make it work with custom components. But I am not an advanced programmer; you may be able to figure out how to make it work.

          Also, you may want to look at Flex 3, which has a new ResourceManager and a lot more support for language/locale switching at runtime.

          However, I said similar because in both of the above, you have to compile something: either the whole application, or, in Flex 3, you can compile and use separate resource modules (SWFs) which can be called at runtime.

          I have done what you want, using ColdFusion (Remote Object). In that case, any changes you make in ‘.properties’ files will show up in your app. But that is a whole new ball game.

          If you work out the problem, please post here.


          • 3. Re: Refferencing  ResourseBundle Externaly at Runtime
            JKohn99 Level 1
            We used a slightly different approach to allow dynamic language switching given that Flex 2 uses a static approach. Actually our solution was designed in Flex 1.5.

            We retrieve a our catalog via a web service and build a hash table of labels, messages etc. Look up is much faster then use e4x searching the xml.

            We use a singleton class to fetch the label , message text dynamically
            so in our label components we do:

            <mx:Label x="10" y="54" text="{TranslationHandler.getInstance().getHashedMsg('finder.search.text')}"/>

            Similar for showing messages to the user.

            Every mxml components listens for a custom event "newCatalog" so if
            the user switches languages, a new catalog is fetched and the newCatalog
            event is dispatched.

            Affected components call executeBindings(true);

            Some text (like Grid Headings) will not refresh in this manner so
            we handle those manually in the newCatalog event handler.

            We could have used an itemRenderer for this but it would fire all the time.

            I haven't looked at the Flex 3 changes for this so I can't comment on that.