Flash Variables in Xcelsius

5

Within a Adobe Flash application, or in this case Xcelsius, you can bind variables that are utilized through out the application during runtime. The benefit of Flash variables within an Xcelsius generated SWF is an ability to push values into the model when embedded inside of a HTML page. In most use cases, you would want to use Flash Variables to push global session variables that you may want to consume and re-use. Examples include: Session tokens, user IDs, and parameters passed from other embedded scripts or controls.

First we will define a variable within Xcelsius.
For Xcelsius 4.5
1. Once Xcelsius is loaded, go to File>Export Settings.
2. Click on the “Define Variables” button.
3. Define your variable name and bind it to a cell. In this case, I named my value sessionID.

4. Generate your SWF.
Now your SWF file is configured to consume a Flash variable

For Xcelsius 2008
1. Open the Data Manager, Data>Connections.
2. Click on the “Add” button. Then select Flash Variables.
3. Add a new variable
3. Define your variable name and bind it to a cell. In this case, I named my value sessionID.
4. Generate your SWF.

There are two ways to push the variable into the SWF.

1. The Adobe Flash player enables a SWF to consume data directly from the HTML for which it is loaded. In a scenario where you are dynamically generating your HTML page, you can pass variables into the SWF on load. You can also use Javascript to dynamically change the variables during runtime, enabling other HTML embedded controls to pass data into the SWF without reloading the HTML page. An HTML nested flash variable would look something like this within an OBJECT tag:

2. The Adobe Flash player also enables a SWF to consume data directly from defined parameters within a browser or path for which it is loaded. This works great for passing parameters from one SWF to another if they are loaded on separate HTML pages.

You can try the example below by entering a value, then launching another HMTL page where we consume the variable. You will be launching a URL that looks something like this:
http://ryangoodman.net/blog/flashvar.swf?sessionID=test

Share.

5 Comments

  1. The drawback with the second approach is that some browsers don’t allow more than 1024 characters in URL.

    Former one is always safe. But it can’t be used to invoke a parameterized SWF from a XCelsius file.

  2. FS Command is a method that was developed to enable a Flash movie for communicating with the Flash player (active X controller). I have seen the FS Command coupled with a VB and Javascript to pass single variables between SWF files. Send me an email and I can send you an example.

  3. Hi Ryan,

    Is it possible to pass a parameter from Crystal Designer 2008 to an embedded Xcelsius 2008 swf component using flash variables.

    Also, could you email me the sample you are mentioning.

    Thank you.

Leave A Reply