سؤال

I'm trying to use resourceManager in Flex for some localization. I'm having a strange problem where it works fine in the first file that I tried it in, but in the second it won't even compile.

Both files have

import mx.resources.ResourceBundle;

at the top and

[ResourceBundle("Hurley")]

above the class definition. The first one compiles fine, and pulls the text from the resources correctly at runtime.

The second file (which is in the same project but a different folder), will not compile, and every mention of resourceManager gives an error of "1120: Access of undefined property resourceManager."

For the two different uses:

In the file that works:

public function SeasonsComboBox() {
    this.labelFunction = function(obj:Object):String {
        return resourceManager.getString('Hurley','Season_word') + " " + obj.number;
    };
}

And the file that doesn't work:

public function getCarousels(seriesId:String, callback:Function):void {
    [...]
    ExternalInterface.addCallback("getCarouselsFailure", function():void {
            Alert.show(resourceManager.getString('Hurley','CarouselsFailure_text'), "Error", Alert.OK);
        });
    [...]
    }

I can't think of anything different I did in either file.

Edit, Solved:

resourceManager is defined in all UIComponent subclasses. The file that worked imported ComboBox. The files that didn't don't. In those files, I can make it work by calling:

ResourceManager.getInstance()

More information here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/resources/IResourceManager.html

هل كانت مفيدة؟

المحلول

The reason that you can't access the reourceManager property, is because it is probably not defined.

It is defined in UIComponent, so any class that extends a UIComponent that will have it defined. But, otherwise you have to define it yourself.

You can do so using something like this:

public var resourceManager:ResourceManager = ResourceManager.getInstance();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top