Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Monday, January 9, 2012

L10n in Flex Quick Guide

Recently I was looking into localization of my Flex project, not to support multiple language, but to support different server environment setup.

So I came up with two options:
  1. Using l10n property file:
    1.  Create a locale directory right under the project.
    2. Add a sub directory under locale named with the locale you want to add.
    3. Add the property file under the sub directory (Note this is different than the Java i18n setup which you just create property file in the pattern <Resource Name>_<locale>.properties)
    4. Repeat 2 and 3 if you have more locales to add.
    5. Go to Project Properties and then Flex Compiler, in the Additional compiler argument section add "-locale <locale list seperated by comma> -source-path=locale/{locale} -allow-source-path-overlap=true"
    6. In mxml file add [ResourceBundle("<Resource File Name>")] to metadata.
    7. Wherever you need a resource, use resourceManager.getString('<Resource File Name>', '<Resource Key>').
  2. Passing environment variables as FlashVars:
    1. Add flashvars as parameter in object in jsp file
    2.  In mxml, using FlexGlobals.topLevelApplication.parameters.<parameter key> to get the passed in value
 

Option 2 is obviously easier to setup.  We don't need to add additional property files but reference existing resource setup in Java project.

Friday, December 9, 2011

Flex + Firefox Display Issue

When I first started to look into Flex development, I ran into a strange situation.  My application runs fine in IE, but when I try the same thing in Firefox, the Flash block just disappeared.  It's not even displaying the the install Flash Player message as if I don't have the plug-in installed.

This issue has puzzled me for months till today.  I finally found out the cause from here.  So to make the swf file display, I'll have to define height for all the elements that will parent the file.  ie:
<html>
    ...
    <body>
        ...
        <div id="parent">
            ...
            <div id="child">
                [swf object]
            </div>
        </div>
        ...
    </body>
    ...
</html>

For this to work in Firefox, I need to define following css style:
html, body, #parent, #child {height:100%}