jquery.flash – Who needs swfobject when you have this?
Posted by Qard on October 4, 2009 · 15 Comments
I’ve used swfobject many times before in the past, but I just don’t like it. It works well enough, but in the modern web of high-traffic web apps and Javascript frameworks that give you elegant access to DOM elements it just feels clunky having to go back to the ‘old’ way of doing things…so I decided to make jquery.flash!
Why use it? Well for starters it minifies to just over 2 KB, rather than the 10 KB of swfobject! How about automatic plugin and version detection? How about complete cross-browser compatibility? If jquery.flash isn’t a perfect fit for your flash embedding needs then you are just asking for too much.
How do you use it? Just like this;
<script type="text/javascript">
$(document).ready(function(){
$('.flash').flash({
"src":"your_flash.swf",
"width":100,
"height":100,
"vars":{"name":"value"},
"color":"#fff",
"quality":"high",
"wmode":"transparent",
"access":"domain",
"express":"express_install.swf",
"classid":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
"codebase":"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=",
"plugin":"http://get.adobe.com/flashplayer",
"mime":"application/x-shockwave-flash",
"version":"9.0.24",
});
});
</script>
All arguments are optional and will just be left out if you don’t use them unless they have a default. Everything from classid down has a default. Width and Height, when not declared, will use the current dimensions of the element that is being replaced. Flashvars are passed as a json object to ‘vars’ and are automatically serialized into a query string. If there is demand for it I may add a check to allow already made query strings to be used instead of a json object, but it wasn’t really of any importance to me.
If you have any questions feel free to ask.
jquery.flash.js
jquery.flash.min.js
Filed under Javascript, Projects, Uncategorized, Web Programming, jquery.flash · Tagged with embed, flash, jquery, jquery.flash, swfobject