最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Update flashvars and reload flash with jQuery - Stack Overflow

programmeradmin1浏览0评论

I would like to update the flashvars value argument to view another video:

<param name='flashvars' value='movieId=1002' />

I found out that I can make it work in Firefox by updating the parameter with the extra step of readding the whole flash contents.

$("param[name=flashvars]").attr("value", "movieId=33");
$("embed").attr("flashvars", "movieId=33");
$(".root").append($("#video"));

But this does not work in IE8 as the browser won't refresh the flash contents. Any ideas on how to reload the flash contents without external dependencies like swfobject.js?

I would like to update the flashvars value argument to view another video:

<param name='flashvars' value='movieId=1002' />

I found out that I can make it work in Firefox by updating the parameter with the extra step of readding the whole flash contents.

$("param[name=flashvars]").attr("value", "movieId=33");
$("embed").attr("flashvars", "movieId=33");
$(".root").append($("#video"));

But this does not work in IE8 as the browser won't refresh the flash contents. Any ideas on how to reload the flash contents without external dependencies like swfobject.js?

Share Improve this question edited Oct 5, 2010 at 8:13 Daniel O asked Oct 5, 2010 at 7:12 Daniel ODaniel O 4,6346 gold badges47 silver badges56 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 4

I'm curious about this too. I'm trying to send a new string via flashvars to a SWF that I have no opportunity to change, and just changing the flashvars with jQuery, without having to use externalinterface, is the best option.

// update flashvars
var fv = 'foobar=1';

$("object param[name='flashvars']").attr("value", fv);
$("embed").attr("flashvars", fv);

// create new object to hold it     
var obj = $("object");

// remove existing Flash from DOM
$("object").remove();

// add new HTML to DOM
$("#mviewer").append(obj.html());

If you want to change the flash vars and reload the Flash, you should just remove the SWF from the DOM and embed it again with your new vars (using SWFObject or whatever other method suits your fancy!).

If you want to change the flash vars without reloading the Flash, you're out of luck: there's no officially-supported way. In this case, you should use ExternalInterface to call ActionScript methods that update your values from JavaScript.

Instead of using flashvars, you could use the ExternalInterface AS3 class to send the new value to Flash.

ExternalInterface allows for a two way communication between AS3 & Javascript

Actually, why not use swfobject.js ?

I did like this :

   <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
   <script type="text/javascript" src="js/swfobject.js"></script>

   <div id="qsound"></div>

<script type="text/javascript">
   if(q.sound) {
    swfobject.embedSWF("js/dewplayer/dewplayer.swf", "qsound", "60", "20", "9.0.0", false, {'mp3': 'sounds/'+q.sound}, {'wmode': 'transparent'});
    $('#qsound').show();
} else {
    $('#qsound').hide();
}
</script>
发布评论

评论列表(0)

  1. 暂无评论