Update flashvars and reload flash with jQuery

前端 未结 5 821
花落未央
花落未央 2020-12-29 11:45

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


I foun

相关标签:
5条回答
  • 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.

    0 讨论(0)
  • 2020-12-29 12:19

    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

    0 讨论(0)
  • 2020-12-29 12:26

    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 讨论(0)
  • 2020-12-29 12:27

    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.

    0 讨论(0)
  • 2020-12-29 12:38
    // 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());
    
    0 讨论(0)
提交回复
热议问题