6 description: Wrapper for embedding SWF movies. Supports External Interface Communication.
8 license: MIT-style license.
11 - Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.
13 requires: [Options, Object, Element]
22 var Swiff = this.Swiff = new Class({
34 allowScriptAccess: 'always',
42 toElement: function(){
46 initialize: function(path, options){
47 this.instance = 'Swiff_' + String.uniqueID();
49 this.setOptions(options);
50 options = this.options;
51 var id = this.id = options.id || this.instance;
52 var container = document.id(options.container);
54 Swiff.CallBacks[this.instance] = {};
56 var params = options.params, vars = options.vars, callBacks = options.callBacks;
57 var properties = Object.append({height: options.height, width: options.width}, options.properties);
61 for (var callBack in callBacks){
62 Swiff.CallBacks[this.instance][callBack] = (function(option){
64 return option.apply(self.object, arguments);
66 })(callBacks[callBack]);
67 vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
70 params.flashVars = Object.toQueryString(vars);
72 properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
75 properties.type = 'application/x-shockwave-flash';
77 properties.data = path;
79 var build = '<object id="' + id + '"';
80 for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
82 for (var param in params){
83 if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
86 this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
89 replaces: function(element){
90 element = document.id(element, true);
91 element.parentNode.replaceChild(this.toElement(), element);
95 inject: function(element){
96 document.id(element, true).appendChild(this.toElement());
101 return Swiff.remote.apply(Swiff, [this.toElement()].append(arguments));
106 Swiff.CallBacks = {};
108 Swiff.remote = function(obj, fn){
109 var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');