grinchikins
asked on
Problem passing Flashvars variables in URL with AC_FL_RunContent
Hello,
I've read the tutorials and posts at Adobe but can't get this to work. My url passes this to the page with my.swf movie:
Code:
http://www.etc/myswf.html?var1=3&var2=A
var1 and var 2 are set depending on the button pressed on the previous page.
This is what I have for the code on the page with my.swf - but it doesn't work. Any suggestions?
script language="javascript">AC_F L_RunConte nt = 0;</script>
<script src="AC_RunActiveContent.j s" language="javascript"></sc ript>
html body etc ...
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '800',
'height', '600',
'src', 'myswf',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'myswf',
'bgcolor', '#ffcc00',
'name', 'myswf',
'menu', 'true',
'allowScriptAccess','sameD omain',
'movie', 'myswf',
'FlashVars', 'var1=var1&var2=var2',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae 6d-11cf-96 b8-4445535 40000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600" id="myswf" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="myswf.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffcc00" />
<param name="FlashVars" value="var1=var1&var2=var2 ">
<embed src="my.swf" FlashVars="var1=var1&var2= var2" quality="high" bgcolor="#ffcc00" width="800" height="600" name="myswf" align="middle" allowScriptAccess="sameDom ain" type="application/x-shockw ave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
I have "var1=var1&var2=var2" this way because in myswf.fla movie I pick up var1 = var1 from the URL and var2 = var2.
The old method that I used with JavaScript worked but did not contain the AC_FL_RunContent code which is needed now for IE. I tried to combine the two methods but haven't had success yet.
<script language="JavaScript">
var1 = "some value"; // Set default values in case not set in URL
var2 = "another variable!";
var p=location.search.substrin g(1).repla ce(/\+/g,' ').split("&");
for(var i=0;i<p.length;i++){
v=p[i].split("=");
window[unescape(v[0]).toLo werCase()] =unescape( v[1]);
}
window.alert("var1=" + var1);
window.alert("var2=" + var2);
</script>
... and in the body
<script language="JavaScript">
document.write("<object><P ARAM NAME=FlashVars VALUE=\"var1="+var1+"&var2 ="+var2+"\ ">");
document.write("<EMBED name=\"movie\" src=\"signSearch.swf\" ");
document.write("FlashVars= \"var1="+v ar1+"&var2 ="+var2+"\ " ");
document.write("width=\"80 0\" height=\"600\" type=\"application/x-shock wave-flash \" ");
document.write("bgcolor=#f fcc00"); //Add any additional object parameters you may require such as bgColor, etc
document.write(" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"");
document.write("></EMBED>< /object>") ;
</script>
Thanks!
Charles
I've read the tutorials and posts at Adobe but can't get this to work. My url passes this to the page with my.swf movie:
Code:
http://www.etc/myswf.html?var1=3&var2=A
var1 and var 2 are set depending on the button pressed on the previous page.
This is what I have for the code on the page with my.swf - but it doesn't work. Any suggestions?
script language="javascript">AC_F
<script src="AC_RunActiveContent.j
html body etc ...
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '800',
'height', '600',
'src', 'myswf',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'myswf',
'bgcolor', '#ffcc00',
'name', 'myswf',
'menu', 'true',
'allowScriptAccess','sameD
'movie', 'myswf',
'FlashVars', 'var1=var1&var2=var2',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="myswf.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffcc00" />
<param name="FlashVars" value="var1=var1&var2=var2
<embed src="my.swf" FlashVars="var1=var1&var2=
</object>
I have "var1=var1&var2=var2" this way because in myswf.fla movie I pick up var1 = var1 from the URL and var2 = var2.
The old method that I used with JavaScript worked but did not contain the AC_FL_RunContent code which is needed now for IE. I tried to combine the two methods but haven't had success yet.
<script language="JavaScript">
var1 = "some value"; // Set default values in case not set in URL
var2 = "another variable!";
var p=location.search.substrin
for(var i=0;i<p.length;i++){
v=p[i].split("=");
window[unescape(v[0]).toLo
}
window.alert("var1=" + var1);
window.alert("var2=" + var2);
</script>
... and in the body
<script language="JavaScript">
document.write("<object><P
document.write("<EMBED name=\"movie\" src=\"signSearch.swf\" ");
document.write("FlashVars=
document.write("width=\"80
document.write("bgcolor=#f
document.write(" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"");
document.write("></EMBED><
</script>
Thanks!
Charles
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems there is a conflict between the relatively new method of coding for IE using AC_FL_RunContent and the old way of passing variables. This solution works but only for Flash 8 and above. Would have been interesting to see if there were any more workarounds. In my case I was passing the variables between Flash movies. I may just embed everything into one larger Flash movie.
I've been trying to find a solution for my problem and I think it is the same to the one you had.
I've passed a variable through URL to my flash page. I need to access that variable "id" .
In my flash page the URL reads as follows.
http://localhost/dev/edit_flash.html?id=39
How do I get at the value of "id" in Flash?
I'm using the swfobject 2.0 Generator but what do I put in for a value.
var params = {}; ??
Perhaps flashvars.id = "edit_flash.html?id";
Any help would be appreciated...Thanks!
I've passed a variable through URL to my flash page. I need to access that variable "id" .
In my flash page the URL reads as follows.
http://localhost/dev/edit_flash.html?id=39
How do I get at the value of "id" in Flash?
I'm using the swfobject 2.0 Generator but what do I put in for a value.
var params = {}; ??
Perhaps flashvars.id = "edit_flash.html?id";
Any help would be appreciated...Thanks!
ASKER