Easy Movie Clip Buttons Part 2 of 3: Dynamic Button Placement

Start by downloading and opening the sample file. The first difference you’ll notice from Part 1 is that there are no longer buttons on the stage. Part 1 demonstrated how to dynamically populate existing movie clip buttons. In this part, we’ll take it a step further by dynamically placing the buttons. Here’s our finished product:

As in part 1, I start off by defining my array:var month_array:Array = new Array ({month:"JAN",fullNm:"January"},

As you can see, I like defining my ActionScript arrays as arrays of objects. This allows me to treat the array as a recordset with named columns. I find it much easier to refer to a value by name rather than its index value.

Continue reading "Easy Movie Clip Buttons Part 2 of 3: Dynamic Button Placement"

How to Pass Dynamic URL Variables to a SWF using ColdFusion

Whew, It’s been a LONG time since I posted anything! Lucky I don’t have a big following.

I recently found myself in a situation where I needed a way to pass certain URL variables to a SWF within a ColdFusion page. This may sound easy on the surface but the catch is that the page is dynamic. It never knows which SWF it’s going to call and each SWF can take different URL variables. I ended up with a pretty clean solution that didn’t take many lines of code. Note that I use SWFObject to place my Flash objects (and so should you) and this solution is specific to that method.

I send one URL variable called customvars that contains all of the variable names and values I want to send to the SWF. Variable names and values are separated by commas and each name/value ‘set’ is separated by a semi-colon. It ends up looking like this:


Then, in my CF page I put the following code which converts the customvars string into a CF structure:

<cfset flashVars = structNew() />
<cfparam name=”url.customvars” default=””>
<cfif len(url.customvars)>
<cfloop list=”#url.customvars#” delimiters=”;” index=”customFlashVar”>
<cfset thisRecordName = listFirst(customFlashVar,”,”)>
<cfset thisRecordValue = listLast(customFlashVar,”,”)>
<cfset flashVars[thisRecordName] = thisRecordValue>

Then, in my swfObject code, I loop through the structure assigning the name and variable to swfObject’s addVariables like this:

<cfloop collection=”#flashVars#” item=”key”>

Works like a charm.