PDA

View Full Version : passing query string variable to flash


Navarone
07-16-2009, 06:40 PM
On my web site I have two menu links that I need to target to a flash movie. Each link goes to a separate section of the flash movie. I am using the AC_RunActiveContent script. I set up a variable called id and I am passing the value through url http://lmi-inc.dev.webriverinteractive.com/core_services.aspx?id=core&isOn=6

were id=core corresponds to the frame in the flash movie. Currently I am running two separate web pages. I would like to only have one web page from which the flash movie plays and when you click the html link it takes you to that frame in the flash movie.

I am using javascript qsParm['id'] to capture the "id" but I don't know how the correct syntax so I can add it to the AC_RunActiveContent. Right now I have it hard coded in.

'movie', 'LMI-services?id=core',

How do i add the qsParm['id'] to the line of code above?:confused:



My html code looks like this

<script language="JavaScript" type="text/javascript">
//<!--this java script code checks the isOn state and switches the class to an selected sate-->
var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}
}
}

qsParm['id'] = null;
qs();
// document.write('You selected ' + qsParm['id']);
//alert("isOn="+qsParm['isOn']+ "isMedia="+qsParm['isMedia'] +"isPhoto="+qsParm['isPhoto']);
//document.getElementById('ab').style.backgroundColo r="#000000";
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable version
// embed the flash movie
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
'width', '710',
'height', '500',
'src', 'LMI-services',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', 'LMI-services',
'bgcolor', '#ffffff',
'name', 'LMI-services',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'LMI-services?id=core',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
document.write(alternateContent); // insert non-flash content
}
}
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not support scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content requires the Adobe Flash Player.
<a href="http://www.macromedia.com/go/getflash/">Get Flash</a>
</noscript>




My flash code

//id = "core"; //for testing locally
trace("id= "+id);

//create dynamic text field
this.createTextField("txtName", 10, -50, 20, 300, 80);
//txtName.text = id;


if (_level0.id != undefined) {
// if it is defined...
txtName.text = id;
this.gotoAndStop(_level0.id);
}