Using flash vars – part 1

One of the things you often have to do, is get flash vars from a configuration file into your Flex application.
There are probably quite a few ways to do what I will describe below. This is just the way I chose to do it.

In this part, we’ll discuss how we can pass flash vars.

So, let’s get down to business.
In your Flex project, there is a html-template folder and inside it a index.template.html file. This file is the template from which the final index.html containing the application flash object tag will be generated. In it, you can load
JavaScript, among other things.

We will use this to configure some variables and pass them via the flash object tag.

Under the html-template folder, create a js folder, and in it create a config.js file.
In it, insert the following JS function, which defines a few configuration items and returns a string concatenation of them. You can, of course, define whatever you like in the config definition.

function getConfigAsString () {
var s = ”;
var name = ”;

var o = {
servicesURL: ‘http://your.domain.com/data/flashservices.php’,
servicesPolicyFile: ‘http://your.domain.com/crossdomain.xml’,
};

for (name in o) {
s += name + ‘=’ + escape (o [name]) + ‘&’;
}

return s;
}

Now, we’ll need to import that piece of JS code into the index.template.html file. We can do this by adding the following inside the HEAD tags:

<script type=”text/javascript” src=”js/config.js”></script>

One last thing we need to do, is use the getConfigAsString function. We’ll do this in the flashVars definition in the AC_FL_RunContent definition:

“flashVars”, getConfigAsString (),

Great!
We’re done with configuring and passing the flash vars to the Flex application.

In the next part, we’ll discuss how to analyze the flash vars in the Flex application.

Advertisements

One Response to Using flash vars – part 1

  1. […] flash vars – part 2 By flexblackbelt Categories: Uncategorized In the previous post, we talked about ways to pass flash vars to our flex application. In this post, we’ll […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: