« January 2006 | Main | March 2006 »

February 8, 2006

Localizing Flex Applications

One thing that may not be noticed in the Flex 2 beta is that we now have built-in support for localization. I found out from Mike Peterson that "the new 'Localizing Flex Applications' chapter didn't make it into the Flex Builder help system or LiveDocs, but it is included in the PDF at this URL":

http://www.macromedia.com/go/flex2_devapps_pdf

So you can check out the localizing chapter there and start playing with @Resource and resource bundles.

At the end of the 'Localizing Flex Applications' chapter, there's a simple example of localizing. I've put together the example to download here:

The zip file is out-of-date for the final version of Flex 2. See the documentation for the example.
http://deitte.com/rb_example.zip

We're only supporting compile-time localization for Flex 2, but we've set things up in such a way that adding runtime localization will be easier in a future version. You can still do runtime localization manually, of course. And you may still be able to find an unoffical way to do runtime localization using the existing mechanism, but you'd have to track down Roger Gonzalez on flexcoders and see if he can cook up a way.

Posted by Brian at 3:10 PM

February 5, 2006

Embedding HTML in a Flex application in AS3

An update to this example for the final version of Flex 2 can be found here.

I converted Christophe's solution, Embedding HTML in a Flex application using an IFrame* to AS3. It also now uses ExternalInterface, provides source with a right-click, and has some other minor improvements.

You can try it out here.

You can see the source by right-clicking in the application and selecting "View Source", courtesy of a new Flex Builder feature.

To run it yourself:

1. Install the Flex beta on your machine so that you have the latest player.

2. Get the source to the example.

3. If you are using Flex Builder to edit the source, you'll need to do one thing after creating a project. Go into Properties, then Flex Compiler, and uncheck 'Generate HTML wrapper file'. There is an existing HTML wrapper that shouldn't be overwritten.

4. After modifying the code, copy IFrameDemo.html and IFrameDemo.swf to a webserver and call the html page through the webserver. This is needed in order to not run into a security error. If you do not do this but instead run the html page from the local filesystem, you will get the error "Security sandbox violation: ExternalInterface caller 'file:///IFrameDemo.swf' may not access 'file:///IFrameDemo.html'." I still need to investigate whether this is an expected error.

It's a fairly small application, but there's three TODOs in there, little things that I will look into. I also have a very detailed writeup on my experience of migrating this application. I hope to post this either tomorrow or sometime next weekend.

*whenever I click on a direct link to Christophe's site, I get a server error. It goes away, however, when I reload the page.

Posted by Brian at 2:01 AM