4 Replies Latest reply on Sep 29, 2010 5:50 PM by flexy_flex

    loadResourceModule not overwriting existing bundles

    flexy_flex Level 1

      What I tried:

       

      I include a resource bundle at the top of my app:

          <fx:Metadata>

              [ResourceBundle("GeneralResources")]

          </fx:Metadata>

       

      On a click I attempt to load a new resource bundle:

                  protected function onClick(event:MouseEvent):void
                  {
                      var o:IEventDispatcher = resourceManager.loadResourceModule("resourceModule.swf", true);
                      o.addEventListener(ResourceEvent.COMPLETE, resourceComplete);
                  }

       

       

      Results:

       

      resourceComplete() is called and I receive no error messages, however:

       

      If I use a resource bundle name that matches the one in my app ("GeneralResources") no changes occur.  Even strings and images that don't conflict with the current bundle do not show up.

       

      If I use a resource bundle name that is different from the one in my app (for example "DifferentResources") then I get all strings and images from my resource module.

       

      I tried:

        + Using a single locale, this app is en_US only (same as the module)

        + Setting the update parameter to "true"

        + Calling update() myself

      but I still don't get any overwrites.

       

       

      My goal is to replace my images and strings to change the look of my app dynamically.

       

      Is there another way I am supposed to be doing this?

        • 1. Re: loadResourceModule not overwriting existing bundles
          Flex harUI Adobe Employee

          You may have to make all resources into modules.  I'm not sure you can bake

          a default set in for a locale.

          1 person found this helpful
          • 2. Re: loadResourceModule not overwriting existing bundles
            flexy_flex Level 1

            Thanks for getting back to me.  Do you know if there's a repository of CS5 (Flex 4, Flash 5, etc) examples somewhere?

            • 3. Re: loadResourceModule not overwriting existing bundles
              Flex harUI Adobe Employee

              Don't know about CS5, but for Flex 4, see www.flexexamples.com

              • 4. Re: loadResourceModule not overwriting existing bundles
                flexy_flex Level 1

                Thanks for the URL harUI.

                 

                 

                For future people viewing this thread...

                 

                ResourceManager.loadResourceModule() states:

                "When the module has been loaded, the resource bundles are added to the  ResourceManager, but the localeChain is left unchanged. If the update  parameter is true, the update() method will be called."

                 

                Do  not interpret this to be the same as addResourceBundle().   addResourceBundle() will update the existing resource bundle if you use  the same locale and bundle name.  loadResourceModule() will bounce,  losing the whole new resource bundle (the old one stays intact).

                 

                I've run through a number of scenarios and each time I can only change resources by:

                   1. Load your resource modules before loading your main UI module (if  you have MXML dependencies on resources brought in via fx:MetaData, then  there's no way to remove them without things blowing up)

                  2. Once you're running you can unloadResourceModule() on the resources you want to change (without update)

                   3. Then loadResourceModule() on your new resources (with update)  Note  that this is not an append or update, but rather a change.  Any  resources that were in the original resourceModule and aren't in the new  one are lost.

                 

                If anyone has found another way to do this please correct me.