mike chambers | about

Global Variables within Flex Applications

The question of how to set up global variables in a Flex application came up on the Flex Components list recently, and as it comes up every so often, I figured I would blog one of the answers.

This is actually very easy. Just define a public variable within your main application class, like so:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
			public var foo:String = "bar";

You can then access that variable from anywhere within the Flex application via:


If you need to, you can still make the variable bindable.

Post and questions or suggestions in the comments.

twitter github flickr behance