Skip to: Site menu | Main content

Email LinkedIn


Flash Builder / Flex 4 and Flash vars.

I don't know if this has changed since Flex 3, but I couldn't find any information about how to access Flash vars from within a Flex 4 application. Since the beta was only recently released it's no surprise that documentation is lacking. One thing that I couldn't find was how to access flash vars passed via HTML from within a Flex 4 application.

In Flex 3 I used this:

protected var someparam:String;

protected function applicationCompleteHandler(event:FlexEvent):void {
this.someparam = Applcation.application.parameters.someparam;

In Flex 4 it's a little more intuitive, but not documented (at least not where I could find it).

In Flex 4 do this to grab the flash vars:

protected var someparam:String;

protected function applicationCompleteHandler(event:FlexEvent):void {
this.someparam = this.parameters.someparam;

Pretty simple, but elusive.

Boolean() vs "as Boolean"

I came across an interesting quirk in Flex today.

I was trying to convert the string "false" to a boolean false. Initially I had this code:

var str:String = "false";
var isDefault:Boolean = Boolean(str);

isDefault always had a value of true. According to the Flex documenation any non empty string value is considered true.

This works as expected:

var str:String = "false";
var isDefault:Boolean = str as Boolean;

Flex FocusManager

I'm still pretty new to Flex so it's no surprise that I find new stuff everyday. While researching form validation I came across this handy little bit of code:


I put this code in my creationComplete() event to send focus to the first form field.

Flex Builder problems with Subclipse and Subversion.

I've been working on a Flex project for a few months now. I just recently decided to add it to my source control system. (I know...I should have done that when I started the project.)

For source control I use Subversion. I've been very happy with it. This is the first Flex project I've worked on, hence it's the first time I've setup a Flex project in Subversion.

I setup my Subversion project just as I've done with other projects. I added all my source code to the project (Except for a few Flex Builder and Eclipse configuration files.)

Everything seemed to work, except for my /www directory. I like to keep my website code inside a subfolder of the Flex Application that will use the sites services. My directory structure looks like this

[Flex Builder Project]

  • controllers
  • model
  • www

My Flex Builder project is set to output to the /www folder. That directory includes the server side services/code that the Flex application uses. Basically Flex is compiling to the root of my local website instance.

I noticed that my www folder could not be added to source control. Each time I would get this dialog box:

I didn't explicitely add any resource in that directory to the ignore list. I even cleared the ignore list and it gave me the same dialog. After clicking yes it appeared to be added to the Subversion project. However, Subclipse still showed the directory as ignorned.

After pulling all my hair out I stumbled across the solution:

I added a /bin directory to my /www directory (/www/bin). Now I have Flex Builder building into that directory and I successfully added the /www folder to the Subversion project.

I'm still not sure what causes the problem. I tried renaming the output folder. Moving it. Nothing worked. I couldn't get it added to the Subversion project. It's probably not a good idea to do that anyway since those files are updated constantly.

Additionally I did not put the following files/folders into the Subversion project

  • .actionScriptProperties
  • .flexProperties
  • .project
  • .settings
  • html-template

URL variables in Flex.

I want to access the URL variables in the URL of the page that launches my Flex application.

The problem:

There is no built-in way to access the querystring or url variables from inside Flex. Any parameters must be passed in as flashvars.

I scoured the web and found this:

How to get URL query-string variables within Flex application

Pretty neat code. Abdul is basically calling the browsers built-in javascript methods for retrieving the URL and querystring values. It doesn't require any additional/custom javascript.

I didn't integrate the class with my code. My needs were simple and could be handled differently within the confines of Flex/Flash.

What this has really done is open my eyes to the ExternalInterface API. The API provides facilities for interacting with the Javascript on the calling page.

If you need easy access to your URL params or just want to see a demo of the ExternalInterface API you should check out Abdul's code.

Flex Developer Journal

Flex now has it's own developer journal at SYS-CON:

<mx:MenuBar> Gotcha.

After almost an hour and some hair pulling I finally figured this one out.

SCENARIO:I want to drive a <mx:MenuBar> from an external XML file.

Easy enough!

Here is my XML:

<menuitem label="Main Menu 1">
<menuitem label="Menu 1 Command 1"/>
<menuitem label="Menu 1 Command 2"/>
<menuitem label="Main Menu 2">
<menuitem label="Menu 2 Command 1"/>


<mx:MenuBar id="mainMenu" width="100%" labelField="@label">
<mx:XML format="e4x" source="assets/mainmenu.xml"/>

No compile errors, but when I run the application i get this:

Screenshot 1

The answer is so simple, but it eluded me. The <mx:MenuBar> has a showRoot attributes that is true by default.

New code:

<mx:MenuBar id="mainMenu" width="100%" labelField="@label" showRoot="false">
<mx:XML format="e4x" source="assets/mainmenu.xml"/>


Screenshot 2

Sometimes Flex is too easy!

Adobe Flex 2: Training From the Source

I finally finished this book. I highly recommend it. The book is geared toward experienced developers looking to jump into Flex development. Flex can be challenging for developers who are used to the traditional page based architecture of web applications. This book does a great job of demonstrating the differences. It also briefly covers some advanced topics like shared objects and skinning. It's not a complete guide, but it provides a good primer so that you can easily move onto more advanced training.

View book on

Scarce Flex Information.

I'm really surprised at the lack of information for good data access strategies in Flex.

I have a Flex application that will use Coldfusion as the back end, but I'd like it to easily adapt to a web service that could be written in PHP, Java, ASP, etc. I can't find any good resources that demonstrate a best practices for this kind of flexibility. There's a lot of talent out there so I know someone has already tackled this problem.

Sweet Flex DataGrid Example.

Here's a really cool example of custom item renderer's in a Flex datagrid:

Custom Item Renderer's

More Entries