incrediblejohn
asked on
How can I dynamically change FlashVars item "streamName" at runtime using ASP.NET?
Trying to figure out how to reference the 2 streamName name/value pairs in the <object> and <embed tags> of a flash control on an .aspx page. I am trying to use asp.net to get the data from a table (no problem there) and put it in the value part of streamName FlashVar.
I can't seem to reference these tags, or insert script brackets inside of the <object> or <embed> tags.
I've tried <%# strstreamNameVariable %>. I could do it if I could get javascript to see these tags and their parameters.
Here is the flash control that works static ok on my webpage(the streamName is the onlything I need to change):
<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="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressi ve.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&MM_ComponentVersio n=1&skinNa me=Clear_S kin_3&stre amName=zyd eco-exampl e&autoPlay =false&aut oRewind=tr ue" />
<embed src="FLVPlayer_Progressive .swf" flashvars="&MM_ComponentVe rsion=1&sk inName=Cle ar_Skin_3& streamName =zydeco-ex ample&auto Play=false &autoRewin d=true" quality="high" scale="noscale" width="400" height="300" name="FLVPlayer" salign="LT" type="application/x-shockw ave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
I can't seem to reference these tags, or insert script brackets inside of the <object> or <embed> tags.
I've tried <%# strstreamNameVariable %>. I could do it if I could get javascript to see these tags and their parameters.
Here is the flash control that works static ok on my webpage(the streamName is the onlything I need to change):
<object classid="clsid:D27CDB6E-AE
<param name="movie" value="FLVPlayer_Progressi
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&MM_ComponentVersio
<embed src="FLVPlayer_Progressive
</object>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can have the literal contain a <script> tag with a single function which does a document.write() of each line in the code you posted.
An alternative method that I've found is to have a bit of script near the bottom of your page (say after the closing body tag and before the closing html tag) which does something like this:
var els = document.getElementsByTag( 'object')
for(i = 0; i < els.length; i++)
{
els.outerHTML = els.outerHTML;
}
I've no idea why it works, but for some reason it does (I used it in a project a few months back). You may have to do the same for the embeds.
An alternative method that I've found is to have a bit of script near the bottom of your page (say after the closing body tag and before the closing html tag) which does something like this:
var els = document.getElementsByTag(
for(i = 0; i < els.length; i++)
{
els.outerHTML = els.outerHTML;
}
I've no idea why it works, but for some reason it does (I used it in a project a few months back). You may have to do the same for the embeds.
ASKER
"I've no idea why it works"
Works for what? Getting rid of the "Click here to activate control".
Hope that is what you mean.
You have good ideas.
Works for what? Getting rid of the "Click here to activate control".
Hope that is what you mean.
You have good ideas.
Sorry, yeah it gets rid of the click here to activate.
ASKER
Yeah, this didn't work. Still have to click twice to start the flash:
<script type="text/javascript">
var els = document.getElementsByTag( 'object');
for(i = 0; i < els.length; i++)
{
els.outerHTML = els.outerHTML;
}
</script>
<script type="text/javascript">
var els = document.getElementsByTag(
for(i = 0; i < els.length; i++)
{
els.outerHTML = els.outerHTML;
}
</script>
See the script below.
It does pretty much the same thing that your script does, however I have it in an external .js file which I reference on each page that needs it. I believe at one point I tried putting it directly on the page and it wouldn't work for some reason, so try the script below in an external .js file.
It does pretty much the same thing that your script does, however I have it in an external .js file which I reference on each page that needs it. I believe at one point I tried putting it directly on the page and it wouldn't work for some reason, so try the script below in an external .js file.
if (navigator.appName == "Microsoft Internet Explorer") (function() {
var onload = window.onload || function(){};
if (document.body != null)
{
document.body.setAttribute('onload', null);
}
window.onload = function() {
onload.apply(this, arguments);
var tags = ['object', 'embed', 'applet'];
for( i=0; i<tags.length; i++ ) {
var elements = document.getElementsByTagName(tags[i]);
for(j=0; j<elements.length; j++)
elements[j].outerHTML = elements[j].outerHTML
}
}
})();
ASKER
Well, I think I should make this another question and award points if it is solved. The code below of yours that I used in a javascript file that is referenced at the bottom of my .aspx page returns the first 3 "hey" alerts. But does not return the last one alert("hey 4") and only a blank screen is displayed with or without the alerts.
alert("hey");
if (navigator.appName == "Microsoft Internet Explorer") (function() {
var onload = window.onload || function(){};
if (document.body != null)
{
document.body.setAttribute ('onload', null);
}
window.onload = function() {
onload.apply(this, arguments);
alert("hey 2");
var tags = ['object', 'embed', 'applet'];
for( i=0; i
alert("hey");
if (navigator.appName == "Microsoft Internet Explorer") (function() {
var onload = window.onload || function(){};
if (document.body != null)
{
document.body.setAttribute
}
window.onload = function() {
onload.apply(this, arguments);
alert("hey 2");
var tags = ['object', 'embed', 'applet'];
for( i=0; i
Hmm, if nothing is showing up on the page, then it wouldn't get into the last "hey" since the source would appear to be empty. Perhaps there's a malformed tag on the page which is causing it not to render anything?
ASKER
Well, I take out the script reference and then the page loads.
There is a macromedia flash version detector in the body onload already.
There is a macromedia flash version detector in the body onload already.
That could be effecting it some how, I'm not sure.
ASKER
Here is my working code that models your soluton, thank you very much!
Dim sbFlashPlayer As New StringBuilder
'FOR IE BROWSERS
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
'FOR ALL OTHER BROWSERS
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
sbFlashPlayer.Append("")
sbFlashPlayer.Append(Envir
objFlash.Text = sbFlashPlayer.ToString