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.
The first part is to send your variable(s) to the containing page
[sourcecode language=”ActionScript3″]
function raiseClick(e:MouseEvent):void
{
var stClicked:String;
stClicked=e.currentTarget.name.toString()
if(ExternalInterface.available) {
ExternalInterface.call("showFancyBox", stClicked);
}
}
[/sourcecode]
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() {
$("a.flashOver").fancybox({
‘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
$(‘#inline’).trigger(‘click’);
alert("toast")
// 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"});
}
</script>
[/sourcecode]
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"
};
}
stContinent=flashVarData.path;
[/sourcecode]