When I use Flex, I make extensive use of Resource Bundles for all but the most basic applications. In short, they allow you to keep all of your static string values (and non-string values) separated out of your code. That way, down the line it’s a very easy change when you want to localize the site in another language, rebrand it for another audience, or when a client asks you to change a button label or error message. Granted, this level of detail isn’t always necessary but I think it’s a good habit to get into even if it’s overkill for some projects.
But resource bundles can’t help you in every scenario. I often find myself needing to construct a sentence with live data inserted. For this, the resource strings are less helpful. For example, how would you write:
"At " + time + ", you received a message from " + userName + "."
With resource strings, you would have to do something like
at=At message=, you received a message from period=.
Which completely negates the whole point of using resource bundles. What to do?
Token replacement

What I really wanted was a way to inject data into the string. I’ve seen this done by use of tokens in other languages like Objective-C so I thought I’d give it a try. The result was surprisingly lightweight.
I created this utility that lets you use tokens (delimited by % signs) that can be replaced by live data when you retrieve the resource. Using this class, the example above would look more like this:
receivedMessage=At %time%, you received a message from %userName%.
// then in your code
trace(ResourceStringUtil.getResoureceStringWithTokens("receivedMessage", {time: "11:49", userName: "Mims"}));
// displays
At 11:49, you received a message from Mims.
Here’s the source code Feel free to use it and modify it for your purposes.