// *** THE METHOD *** //
Element.implement({
loadSwiff: function(path, options){
var swiff = new Swiff(path, options);
this.store('swiff',swiff);
swiff.inject(this);
return this;
}
});
// *** USAGE *** //
$('load').addEvent('click',function(){
$('test').loadSwiff('http://ryanflorence.com/test.swf',{
id: 'test_movie',
width: 550,
height: 200,
params: {
wmode: 'transparent'
}
}).addClass('swiffified'); // the whole point is to chain it like so
$('log').set('disabled',false);
$('load').set('disabled',true);
});
$('log').addEvent('click',function(){
console.log($('test').retrieve('swiff'));
});
<h1>loadSwiff Test - The element should have a flash video loaded into it</h1>
<p>
<button id="log" disabled="true">Log swiff object to console</button>
</p>
<div id="test">
<button id="load">Load Swiff</button>
</div>
body {
font-family: Helvetica, arial;
background: #fff;
}
h1 {
color: #0094d5;
margin-bottom: 1em;
}
div#test {
border: solid 5px #e40053;
}