views:

35

answers:

1

I have a button in Flex that has mx:skin set to an image, but i want to set it so that when i change the language the image change as well. The code is something like the following:

<mx:Button id="btnMain">
    <mx:skin>@Embed(source='main/resources/images/ABA_MAIN_IDLE.png')</mx:skin>

The way i handle i18n is by using a class called ConfigI18n that wraps the ResourceManager, and i just have to call it like i would with ResourceManager:

<mx:Label text="{ConfigI18n.getInstance().getString('someLabel')}"/>

I tried using the i18n within mx:skin but didn't work. Anyone also had the same problem or already did it?

+2  A: 

Use IResourceManager.getClass().

In your resource file (messages.properties, say), embed the image:

idleImage=Embed("assets/images/idle.png")

Then in your code (using your example, but not sure of skin syntax):

<mx:Button id="btnMain">
    <mx:skin>{resourceManager.getClass("messages", "idleImage")}</mx:skin>
</mx:Button>
Michael Brewer-Davis