Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 22nd, 2012  |  syntax: None  |  size: 3.44 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var SWFPROTOTYPE = Y.SWF.prototype,
  2.     SWFINSTANCES = Y.SWF._instances,
  3.     SWFEVENTHANDLER = Y.SWF.eventHandler,
  4.     Event = Y.Event,
  5.     Escape = Y.Escape,
  6.     SWFDetect = Y.SWFDetect,
  7.     Lang = Y.Lang,
  8.     uA = Y.UA,
  9.     Node = Y.Node,
  10.     FLASH_CID = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
  11.     FLASH_TYPE = "application/x-shockwave-flash",
  12.     FLASH_VER = "10.0.22",
  13.     EXPRESS_INSTALL_URL = "http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?" + Math.random(),
  14.     EVENT_HANDLER = "SWF.eventHandler",
  15.     possibleAttributes = {align:"", allowFullScreen:"", allowNetworking:"", allowScriptAccess:"", base:"", bgcolor:"", menu:"", name:"", quality:"", salign:"", scale:"", tabindex:"", wmode:""};
  16. Y.SWF = function(p_oElement, swfURL, p_oAttributes) {
  17.  
  18.     this._id = Y.guid("yuiswf");
  19.  
  20.  
  21.     var _id = this._id;
  22.     var oElement = Node.one(p_oElement);
  23.    
  24.     var p_oAttributes = p_oAttributes || {};
  25.  
  26.     var flashVersion = p_oAttributes.version || FLASH_VER;
  27.     var flashVersionSplit = (flashVersion + '').split(".");
  28.     var isFlashVersionRight = SWFDetect.isFlashVersionAtLeast(parseInt(flashVersionSplit[0], 10), parseInt(flashVersionSplit[1], 10), parseInt(flashVersionSplit[2], 10));
  29.     var canExpressInstall = (SWFDetect.isFlashVersionAtLeast(8,0,0));
  30.     var shouldExpressInstall = canExpressInstall && !isFlashVersionRight && p_oAttributes.useExpressInstall;
  31.     var flashURL = (shouldExpressInstall)?EXPRESS_INSTALL_URL:swfURL;
  32.     var objstring = '<object ';
  33.     var w, h;
  34.     var flashvarstring = "yId=" + Y.id + "&YUISwfId=" + _id + "&YUIBridgeCallback=" + EVENT_HANDLER + "&allowedDomain=" + document.location.hostname;
  35.  
  36.     Y.SWF._instances[_id] = this;
  37.     if (oElement && (isFlashVersionRight || shouldExpressInstall) && flashURL) {
  38.         objstring += 'id="' + _id + '" ';
  39.         if (uA.ie) {
  40.             objstring += 'classid="' + FLASH_CID + '" ';
  41.         } else {
  42.             objstring += 'type="' + FLASH_TYPE + '" data="' + Escape.html(flashURL) + '" ';
  43.         }
  44.  
  45.         w = "100%";
  46.         h = "100%";
  47.  
  48.         objstring += 'width="' + w + '" height="' + h + '">';
  49.  
  50.         if (uA.ie) {
  51.             objstring += '<param name="movie" value="' + Escape.html(flashURL) + '"/>';
  52.         }
  53.  
  54.         for (var attribute in p_oAttributes.fixedAttributes) {
  55.             if (possibleAttributes.hasOwnProperty(attribute)) {
  56.                 objstring += '<param name="' + Escape.html(attribute) + '" value="' + Escape.html(p_oAttributes.fixedAttributes[attribute]) + '"/>';
  57.             }
  58.         }
  59.  
  60.         for (var flashvar in p_oAttributes.flashVars) {
  61.             var fvar = p_oAttributes.flashVars[flashvar];
  62.             if (Lang.isString(fvar)) {
  63.                 flashvarstring += "&" + Escape.html(flashvar) + "=" + Escape.html(encodeURIComponent(fvar));
  64.             }
  65.         }
  66.  
  67.         if (flashvarstring) {
  68.             objstring += '<param name="flashVars" value="' + flashvarstring + '"/>';
  69.         }
  70.  
  71.         objstring += "</object>";
  72.         //using innerHTML as setHTML/setContent causes some issues with ExternalInterface for IE versions of the player
  73.         oElement.set("innerHTML", objstring);
  74.        
  75.         this._swf = Node.one("#" + _id);
  76.     } else {
  77.         var event = {};
  78.         event.type = "wrongflashversion";
  79.         this.publish("wrongflashversion", {fireOnce:true});
  80.         this.fire("wrongflashversion", event);
  81.     }
  82. };
  83. Y.SWF.prototype = SWFPROTOTYPE;
  84. Y.SWF._instances = SWFINSTANCES;
  85. Y.SWF.eventHandler = SWFEVENTHANDLER;