Opinion Disclaimer

Setting up Resource Bundles

In last week’s Flash Friday post I wrote about using resource bundles to handle embedded fonts. I also left out any instructions about how to set up your project to use resource bundles, instead telling the reader to search the interwebs. I also said I would provide one of my own instructions so here it is.

Project Setup

Your project needs to be able to find your resource bundles so they need to live in your source path. You could place the bundles in the same folder as your source code, but I find that feels a little disorganized. Instead create a folder for your resource bundles and add it to your source path.

In other tutorials they talk about using resource bundles for localization. If that is the case you can add the files as follows. I’ll assume you are using the en_US locale, otherwise replace all instances of en_US with the locale you are using.

  1. create folder path in your project of: locale\en_US
  2. add the source folder locale\{locale}
  3. add the following to your compiler arguments: -locale=en_US

Now you can place your resource bundles in the locale\en_US folder.

Property Files

Resource bundles are sometimes referred to as property files because you create them in files with a .properties extenstion. The part before the extension is the bundle name, and you would use that to get the information you wanted. For example, you you had a bundle named fonts you would create a file called fonts.properties. If you were paying attention to my previous article you probably saw me use this same bundle name.

Inside the property file

The property file is fairly simple. It is just a key/value pair separated by an equal sign(=). A simple resource bundle that stores text strings might be called text.properties and look like the following.

# text.properties
 
hello=Hello World!
goodbye=Good-bye cruel world!

You can look back at my font embedding article to see how I embedded fonts. You can use the same method to embed anything that you can embed using the Embed metatag.

Using the properties in the file

The first thing you need to do is add the Resource Bundle metatag somewhere in your project. You only need to use it once per project for every bundle you are going to use. However, once you do this it gets compiled into the project, even if you don’t use the resources. So I would recommend using it in the class(es) that use(s) the bundle.

	[ResourceBundle("fonts")]
	public class MyFontsBundleUsingClass {
		...

Then to use the resources you just need to get an instance of the ResourceManager use one of its functions to get the resource. Here is an example for grabbing a String from my text.properties file I created earlier.

	var resources:IResourceManager = ResourceManager.getInstance();
	var hello:String = resources.getString("text", "hello");
	var goodbye:String = resources.getString("text", "goodbye");
    Of course you can get more than just strings from a property file. Just choose from the following list of functions in the IResourceManager interface.

  • getString
  • getBoolean
  • getInt
  • getUint
  • getNumber
  • getStringArray
  • getClass
  • getObject

And that is my basic primer on using ResourceBundles in actionscript projects. In the grand tradition of this line of posts I am leaving out many important bits of information. Loading resource bundles at runtime is one of them. I’ll leave that as a web search exercise for the reader until I write an article on that in the future. If there are other bits of information you would like clarity on let me know in the comments.

Tags: , , , , ,

Friday, January 13th, 2012 Flash Friday

2012 – The Year of the Warrior?

Daryl holding the Mens Group 101 DVDAt the eginning of each year, people make resolutions of how they are going to change. I am not different. This year I have already written about one of my resolutions in the new year.

This year another of my resolutions has to do with my Men’s Studies. Recently Men’s Group 101, a partnership between Tripp Lanier(The New Man Podcast) and Jayson Gaydiss, had a New Year sale on their program. The sale seemed good and I was in a resolution mode so I purchased it.

What does this mean!

OMG! Does this mean I’m going to start a men’s group in 2012? Perhaps, I don’t know. However, at the very least, I hope to be a part of one in 2012. You are probably thinking, “That sounds great Daryl, but why would you want to be part of a mens group?”

For me a mens group is yet another way for me to connect with my sacred masculine. Having grown up in an all female household I’ve felt disconnected for a long time. Only recently have I begun to connect with my personal maleness. Now I feel it is time to connect with other men with a desire to connect with the sacred masculine.

Have you ever wished you had a circle of Men who you met with regularly, who “had your back” and were committed to your greatness as a man?

The quote above is from an email I got from Men’s Group 101 that I think sums it up the best. To have a group of guys who have your back when you need it, which includes calling you on your own bullshit, sounds like a way to empower mens towards extra-ordinary lives.

I realize this post doesn’t say much about what exactly will happen. What I’m saying is, I’m open to something happening and I’m taking steps towards it – starting with the purchase of the Men’s Group 101 program. I’m not sure where it will take me but I’ll share with you along the way in future Wednesday Warrior posts.

Have you ever been interested in joining a men’s group? Have you ever been a part of men’s group? Have you known someone else who has? Please share your stories in the comments below. Also, if you are in the Seattle area and you are reading this, write a comment or hit up my contact page.

Tags: , , ,

Wednesday, January 11th, 2012 Wednesday Warrior

Magic Monday – Phone Cam Magic

Recently, I finally broke out my EMC2011 DVD as I begin my resolution in 2012 to get back into magic. Because I was less involved in magic last year I didn’t watch much of the conference live or even semi live. So far I’ve watched the first two discs and I’ve seen and heard some very inspiring stuff. From Rudy Coby‘s talk How To Be The Coolest Magician On Earth to Jonathan Bayme‘s Magic 2.0, I have been inspired by what is possible if you just keep moving forward with you goal in mind.

One of the people who was parto of EMC in 2010 and again in 2011, probably because he is one of the people behind it, is Marco Tempest. The thing I liked in 2010 and 2011 from Marco is his use of technology. He is updating old tricks with the new technology and new media. He is creating all sorts of magic that may not have ever been seen before.

One of the things that he experiemented with was youtube and the perspective of a phone camera. These are great bits that take a little bit of the old and rejuvenate it with the new. Take it away Marco…

That was a fun little video (pun completely intended) to start off the series. In his eighth video entitled “Proximity”, he shows us a little more of the magic behind the perspective of a phone cam. What I like about this video is that it almost feels like he is throwing away some of the magic that he is showing.

As always, I’d love to hear what you think of these bits of magic. Did you like them? Did they wow you? Did they inspire you? Let me know in the comments. With my forthcoming experiment of JAMM Live, I’m wondering how much actual magic performance I should put into it.

Tags: , , , , ,

Monday, January 9th, 2012 Just Another Magic Monday

Mock GOP Cyber Debate

As we enter the 2012 election year, we can already see things heating up on the political front. What does that mean fothe rest of us? Lots of great humor will be coming out over the next year that will have us LOLing and ROFLing.

In the tradition of election year politcal humor, Funny or Die along with Yahoo have put together a Mock Cyber debate among the Republican contenders. All the candidates are played by some well named comedians or former boxer turned reality star.

I’ll be the first to admit that this humor is heavy handed and a bit childish but it is also quite funny. This is a long-ish video but don’t start watching then quit once you get the gist. The jokes get better as the “debate” progresses. Plus, if you stop watching you’ll miss the cherry on top ending – Obama’s response.


I’m somewhat political by nature, in that I take politics fairly seriously. However, it is just as important to laugh every once in a while as it is to take the actual politics seriously. Enjoy, and let me know what you think in the comments.

Tags: , , , , ,

Sunday, January 8th, 2012 Sunday Funnies

Resource Bundles and Fonts

If you’ve been working with Flash for a while, especially FlashBuilder, you’ve probably heard of resource bundles. If you are like me you heard they had something to do with localization. Then you quickly forgot about them. The truth is they aren’t only for localization. In fact, they are a really good way to centralize and manage resources in actionscript project. They also happen to work really well for localization. So if they do more than just localization, what are resource bundles.

What are Resource Bundles

I hate to state the obvious, but resource bundles are bundles of…wait for it…resources! So with that the next question is, “What is a resource?”

    A resource could be a…

  • …String
  • …Image
  • …Config Value
  • …Font

Why would you want to use them?

Okay, now you know what resources are. You’ve managed these resources in other ways. Why would you want to use resource bundles over the way you already do?

    Here are a few good reasons

  • 2 words, cleaner code
  • easier localization
  • change text, configs, etc. in one spot

How to setup

Before we get into using resource bundles with fonts, it is important to know how to set them up. Also you might want to know how to use them with the other, simpler types of resources. There are many great articles already available online if you want to search. I plan to write a “how to setup resource bundles” post next week so check back then.

I hate fonts (but I understand they make stuff look good)

I have always dreaded working with embedded fonts on a flash project. Even though I’ve done it many times, and should know how, each project has brought its own wrinkle that has caused grief for me. Embedding fonts via resource bundles gives you more control over the specifics of the font. Also, since it is built into development with the Flex SDK, you can more readily change them for your needs right in the project. Need to embed more characters? Change to/from CFF embedding? Just type in the appropriate text and you are done. Depending on your development environment you may need to clean your project.

One other point, I recently work on a localization project for game that was already live. Even though we had all the text strings externalized this project sucked and was slow going. If I had my strings, and other resources, setup in resource bundles I would have been halfway done with the project before I even started. So enough talk, how can we use resource bundles to help with font embedd?

Embedding fonts with resource bundles

A font gets embedded in a resource bundle much like an image get embedded, using the Embed metatag. In fact it is awfully similar to using the Embed metatag as you would in an actionscript file.

It might look something like this:

#a file called fonts.properties

AFontDesignersLove="ComicSans"
ComicSans=Embed(\
	source="./assets/fonts/comic.ttf", \
	fontName="ComicSans", \
	embedAsCFF="false", \
	mimeType="application/x-font", \
	advancedAntiAliasing="true", \
	unicodeRange="U+0020-007E")

The backslash(\) is useful in property files to make long entries more readable. I’m all about readable, editable code.

To use this font in its current form would work like this:

[ResourceBundle("fonts")]
public class MyFontUsingClass {
 
// put some other code here
 
	var resources:IResourceManager = ResourceManager.getInstance();
	var fontName:String = resources.getString("fonts", "AFontDesignersLove");
	var format:TextFormat = new TextFormat(fontName, FONT_SIZE);
 
	_questionField = new TextField();
	_questionField.defaultTextFormat = format;
	_questionField.embedFonts = true;
 
// put some more code here

You probably noticed a couple things here:

  • I lied – designers hate Comic Sans
  • I also put the font name (string resource) in the property file and just used it to bring in the font.

Once you use the resource bundle metatag in your code for a bundle that has fonts, those fonts are already embedded in your code. There is no need to do the old Font.registerFont() silliness. At least not when you compile the resource bundle into your swf.

The above code is still a bit heavy and I’d hate to have to write it every time. My advice is to clean it up into something that looks a bit more like this:

_questionField.defaultTextFormat = Fonts.getFormat();
_questionField.embedFonts = true;

Depending on what type of format data is used, you might need to make this a little more robust than this but aiming towards this will make you enjoy the benefits gained from embedding fonts this way. For now, I leave this as an exercise for the reader. I plan to write an article on some resource bundle good practices* in the future.

Tags: , , , ,

Friday, January 6th, 2012 Flash Friday

Resolutions and Chimp Magic

Sparkly Daryl the magicianAs we end 2011 one of my resolutions is to once again re-acquaint myself with the magical arts. In the past year I haven’t really been practicing at all. At the same time, early last year there was a joke where I mentioned the phrase “Magician 24/7” and it turned into a thing that led to the picture you see at the top of this article. On the other hand I learned a lot about how I can be practicing that will bring the joy back into magic. I got this insight from my study of improvisational comedy.

What does this mean? It means in the coming year I am going to attempt a regular magic vidcast called JAMM Live. Where as the posts on my blog have the meaning of JAMM be Just Another Magic Monday the JAMM in JAMM Live will stand for Just Another Magic Meeting. This is because I don’t believe Mondays will be a good day for me to do these on any sort of regular basis. I will figure it out in the next few weeks so keep an eye out for the vidcast. Also, look for more, regular JAMM posts on Mondays for this blog.
[ad#Ellusionist]What about the fun? Well, since I am known for my interest in magic I do get interesting videos sent to me from time to time. So this week I leave you with a bit of Chimp Magic. This guy really blows the socks off of a chimp who just loves his act. Given that chimps process things differently than us, and as such don’t have the same expectations, that is pretty dang cool. Enjoy… the chimp did.

For those who don’t see the connection of the video and my point on resolutions, remember that 2011 was the year that Rise of the Planet of the Apes was redone. Just kidding, just bringing the fun back to magic. Do you have any fun magic you’d like to share. Let me know in the comments below.

Tags: , , , , ,

Monday, January 2nd, 2012 Just Another Magic Monday

Billy Quan – Enter the New Year

Mind Your Manners with Billy Quan logoMy Sunday Funnies posts are usually posted, you guessed it, on Sundays. However, with January 1st being on a Sunday I decided to post an early version of the post as a New Year’s service announcement.

I have posted a few things from Almost Live! in the past. With 2012 being the year of the dragon (or at least it will be on January 23rd) I thought I’d provide the message via a psuedo-Chinese themed skit they often did on the show, Mind Your Manners with Billy Quan.

This episode of Mind Your Manners features Billy (played by Darrell Suto) getting ready for a New Year’s Eve party. Suddenly a party crasher (John Keister) comes along and ruins his party before it even starts. Billy then proceeds to teach him some manners, Billy Quan Style.

Unfortunately, embedding has been disabled by request on this video so you’ll have to watch it over on youtube. I hate that setting but at least the video is worth the extra click.

Tags: , , , , , , ,

Saturday, December 31st, 2011 Sunday Funnies

Its getting real…funny

I’ve been itching to write a blog post for a while. However its been a busy time as I’ve moved from San Jose to Seattle. Well now I’m getting settled and I’m ready to write about something I’ve found funny for a few months. If you have shopped at any place similar to Whole Foods the song and video for ‘Whole Foods Parking Lot’ should at least have you break into a chuckle.

You’re the most annoying dude I’ve ever seen bra
Could you please move you’re right in front of the Quinoa

So here’s a little taste of that humor in video form

Not one to miss humorous music I also came across another song by DJ Dave and company. Following his hipster trend we saw in the previous video he follows with ‘Yoga Girl’. It has some silly lyrics in it as well that a white boy like me (or anyone who would make fun of a white boy like me) can laugh at.

You wanna meditate with me?
I’m like…o/uhmm

[ad#Google Adsense]
Also there is some pretty crazy yoga poses in this video.

And you haven’t had enough of the boys of Fog and Smog there is one last thing I’d like to show you. It seems they did a little spot for Hyundai that is right in line with their same rap humor. Also, ’tis the holiday season and this video is from a holiday promotion. Nice!

Hyundai Holidays feat. Fog and Smog from David Wittman on Vimeo.

I’m a big fan of humorous music. I follow Wierd Al on Twitter, he’s funny there too. Do you know some other funny music I should check out. I’m all ears.

Tags: , , , , , , , ,

Sunday, December 11th, 2011 Sunday Funnies

My farewell show at Comedysportz San Jose

As you may have heard, from recent posts, I am moving to Seattle for a new job. They wanted me to start October 31st but I wasn’t having any of it. Not because it is Halloween, though I did love Halloween at Gaia, but because I had an improv show to do November 3rd and I wouldn’t miss it for the world. I have had a great time training at Comedysportz San Jose and had a blast with my fellow improvisers so I had to see how we’d all do at a honest to goodness Comedysportz formatted show.

For your information, we did great. Also, my wife got some shaky video of most of the show. So sit back, relax and have a laugh at my expense.

BTW – 80′s bands should have been my category. Next time I will not falter!

If you enjoyed this, you might also enjoy my previous show that I posted here during the summer. That is long form improv but still quite fun.

If you enjoyed this please tell all your friends by tweeting, posting to facebook, google plus, tumblr, myspace whatever. If you didn’t enjoy this…shhhhhh…no one likes a whiner. ;) Seriously, I’d love to hear what you think of the show. If you have any samples of your own improv and/or stand up comedy I’d love to see them as well. Good alternatives for the game of 185? 80s bands that I should have said(this could be a long list)? Post them in the comments.

Tags: , , , , , , , ,

Saturday, November 5th, 2011 Improv, Sunday Funnies

Halloween themed? – Just Another Magic Monday

In honor of Samhein and/or Halloween I wanted to bring back a classic from my favorite magician, Jeff McBride. Why Jeff McBride? Well, because he is best known for his mask routine. Many who have already followed my JAMM posts have seen his most popular mask routine but I need to show the one that floored me way back when. I couldn’t find that original post (it has been removed by the user) but I found another performance from TV that incorporates it.

So here it is. Jeff McBride’s early Mask routine in honor of All Hallow’s Eve:

[ad#Ellusionist]
Do you have a favorite magic routine for Halloween? Do you perform it? Do you have a video? I’d love to see/hear about it in the comments.

Tags: , , ,

Monday, October 31st, 2011 Just Another Magic Monday
Opinion Disclaimer
Add to Google