Filed under Flex

Don’t Panic.

by

Dear Flash & Flex Interactive Developers, keep calm and carry on. The news from Adobe seems like a big deal now but I’m not sure that it’s soon enough to judge what the long term impact will be. In my opinion, it’s not yet time to panic (is it ever?) and in this post, I’ll talk about why.

First, if you don’t know what I’m talking about, check out the news. I think the best explanation comes from Mike Chambers’ Blog and a corresponding post on the Flex Team’s Blog.

Don't panic! Take a deep breath and look at this cute bunny

Continue reading

Using %tokens% with Flex resource bundles

by

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

tokens
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.

Tagged , , ,

Using ant for Flex – a no B.S. guide – Part 4 of 4

by

Now that you’ve been through 3 exhaustive tutorials on ant for flex, it’s time to use your knowledge you’ve gained to turn your back on the built-in Flex compiler and switch to ant for your builds. This part applies to FlexBuilder (and FlashBuilder) users only although it may apply if you’re using some other eclipse-based plugin. If you’re using another program like TextMate or Flash CSx, you can skip this article.
Continue reading

Tagged , , , , , ,

Using ant for Flex – a no B.S. guide – Part 3 of 4

by

This third installment talks about tips and tricks for using ant with version control systems.
Continue reading

Tagged , , , ,

Using ant for Flex – a no B.S. guide – Part 2 of 4

by

In this part, I get more nitty-gritty about working with flex’s ant tasks.
Continue reading

Tagged , , , , ,