Passing flash variables between flash files using jquery and fancybox

How to use an embeded pass variables between flash files using the jquery pluging fancy box.

In this example we need to select a continent of the world to then load a larger flash file which is then zoomed into this area.



View example

The first part is to send your variable(s) to the containing page

[sourcecode language=”ActionScript3″]
function raiseClick(e:MouseEvent):void
var stClicked:String;
if(ExternalInterface.available) {"showFancyBox", stClicked);
The above code then passes the string stClicked to the page calling the fancyBox overlay

[sourcecode language=”js”]
<script type="text/javascript">
// showFancyBox function called by flash
function showFancyBox(my_href)
// instantiate fancybox
$(document).ready(function() {
‘padding’ : 3,
‘overlayOpacity’ : 0.8,
‘overlayColor’ : ‘#000’,
‘width’ : 700,
‘height’ : 365,
‘content’ : ‘<div id="flashOverlay">Add Alt content for overlay.swf here.</div>’,
‘autoDimensions’ : false,
‘scrolling’ : ‘no’,
‘hideOnContentClick’: false

// trigger click
// embed swf on flashOverlay div
var flashvars = {
path: my_href
swfobject.embedSWF("worldmap.swf", "flashOverlay", "700", "365", "10", "./swf/expressInstall.swf", flashvars, params, {id:"swfOverlay"});


In the called flash file you can then access the passed variable by using the flashVarData, in the example below i fiurst check if there is a value and then assign a default value if nothing was passed

[sourcecode language=”ActionScript3″]
if(flashVarData["path"] == undefined) {
flashVarData = {
path: "conEurope"