Friday, February 21, 2014

How to replay a swf movie on jquery button click

1. Embedded flash movie

<object data="http://wwwimages.adobe.com/www.adobe.com/multimedia/en_us/get/flash/flash_installed_728x170.swf" type="application/x-shockwave-flash" id="flash_99674493" width="680" height="316">
    <param name="movie" value="http://wwwimages.adobe.com/www.adobe.com/multimedia/en_us/get/flash/flash_installed_728x170.swf">
    <param name="wmode" value="opaque">
</object>

<a href="javascript:restart();">Restart swf</a>

2. jQuery

var restart = function() { 

   var flashObject = jQuery("object");
   var flashOriginal = flashObject.html();
   var flashSrc = flashObject.attr('data');

   flashObject.find('param').remove(); 
   flashObject.attr('data',flashSrc);       
   flashObject.html(flashOriginal); 

}

Working Demo

No comments:

Post a Comment