msnbc.components.FlashComponent = msnbc.components.Component.extend({ init: function(){ this._super(); //this.setupEmbedParameters(); }, setupEmbedParameters: function(params){ this.defaultParams = { id:'fl'+Math.floor(Math.random()*100000), width:976, height:400, allowscriptaccess: 'always', wmode: "opaque", flashvars: { } }; this.embedParams = params.embedParams || {}; this.embedParams.src += '?domain=' + window.location.host; // extend embed params against defaults with deep copy flag this.embedParams = jQuery.extend(true, this.defaultParams, this.embedParams); msnbc.log(this.embedParams); }, enableFlashMessaging: function(){ this.__exlisteners = {}; // add some new flashvars jQuery.extend(this.embedParams.flashvars, { ext_service:"notifyComponent", ext_parent:"msnbc.document.flashBridge['"+this.embedParams.id+"']" }); // we need to have a global refrence to 'this' so that flash can call this.notifyContainer var beacon = msnbc.namespace("msnbc.document.flashBridge."+this.embedParams.id); beacon = this; this.flashMessaging = true; }, insertOn: function(element){ $(element).flash(this.embedParams); //if (jQuery.browser.msie) { // var stuff; // $(element).flash( // self.embedParams, // {}, // function(htmlOptions){ // stuff = jQuery.fn.flash.transformObject(htmlOptions); // } // ); // var el = $(element)[0]; // el.innerHTML = stuff; //} else { // $(element).empty().flash( // self.embedParams // ); //} }, addFlashListener: function(msg, callback){ if (!this.__exlisteners[msg]) this.__exlisteners[msg] = []; this.__exlisteners[msg].push(callback); }, notifyComponent: function(msg, params){ var ls = this.__exlisteners[msg]; if (!ls) return; for (var i = ls.length - 1; i >= 0; i--){ return ls[i].call(this, params); } }, callFlash: function(method, params){ e[method].call(e, params); } });