Animation flash en arriere plan + swfobject

Animation flash en arriere plan + swfobject - Web design - Graphisme

Marsh Posté le 04-04-2011 à 10:26:59    

Salut,  
J'ai créer un .swf en passant par flash catalyst et flash builder et j'aimerais pouvoir faire passé mon .swf en dessous d'un iframe. J'ai reussi a la faire sans l'utilisation du swfobject.js mais avec mon fichier swf créé sous flash builder je suis obligé de garder le swobject.js . J'ai lu sur le net que la commande à rajouter est   -->  so.addParam("wmode", "opaque" ); mais je ne sais pas ou la placer dans mon swfobject.js
 
Voila mon swfobject.js :

Code :
  1. /*! SWFObject v2.2 <http://code.google.com/p/swfobject/>  
  2. is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>  
  3. */
  4. var swfobject = function() {
  5. var UNDEF = "undefined",
  6.  OBJECT = "object",
  7.  SHOCKWAVE_FLASH = "Shockwave Flash",
  8.  SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
  9.  FLASH_MIME_TYPE = "application/x-shockwave-flash",
  10.  EXPRESS_INSTALL_ID = "SWFObjectExprInst",
  11.  ON_READY_STATE_CHANGE = "onreadystatechange",
  12.  win = window,
  13.  doc = document,
  14.  nav = navigator,
  15.  plugin = false,
  16.  domLoadFnArr = [main],
  17.  regObjArr = [],
  18.  objIdArr = [],
  19.  listenersArr = [],
  20.  storedAltContent,
  21.  storedAltContentId,
  22.  storedCallbackFn,
  23.  storedCallbackObj,
  24.  isDomLoaded = false,
  25.  isExpressInstallActive = false,
  26.  dynamicStylesheet,
  27.  dynamicStylesheetMedia,
  28.  autoHideShow = true,
  29. /* Centralized function for browser feature detection
  30.  - User agent string detection is only used when no good alternative is possible
  31.  - Is executed directly for optimal performance
  32. */
  33. ua = function() {
  34.  var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
  35.   u = nav.userAgent.toLowerCase(),
  36.   p = nav.platform.toLowerCase(),
  37.   windows = p ? /win/.test(p) : /win/.test(u),
  38.   mac = p ? /mac/.test(p) : /mac/.test(u),
  39.   webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1" )) : false, // returns either the webkit version or false if not webkit
  40.   ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/ [...] s-to-know-if-your-browser-is-ie.html
  41.   playerVersion = [0,0,0],
  42.   d = null;
  43.  if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
  44.   d = nav.plugins[SHOCKWAVE_FLASH].description;
  45.   if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
  46.    plugin = true;
  47.    ie = false; // cascaded feature detection for Internet Explorer
  48.    d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1" );
  49.    playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1" ), 10);
  50.    playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1" ), 10);
  51.    playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1" ), 10) : 0;
  52.   }
  53.  }
  54.  else if (typeof win.ActiveXObject != UNDEF) {
  55.   try {
  56.    var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
  57.    if (a) { // a will return null when ActiveX is disabled
  58.     d = a.GetVariable("$version" );
  59.     if (d) {
  60.      ie = true; // cascaded feature detection for Internet Explorer
  61.      d = d.split(" " )[1].split("," );
  62.      playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
  63.     }
  64.    }
  65.   }
  66.   catch(e) {}
  67.  }
  68.  return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
  69. }(),
  70. /* Cross-browser onDomLoad
  71.  - Will fire an event as soon as the DOM of a web page is loaded
  72.  - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
  73.  - Regular onload serves as fallback
  74. */
  75. onDomLoad = function() {
  76.  if (!ua.w3) { return; }
  77.  if ((typeof doc.readyState != UNDEF && doc.readyState == "complete" ) || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body" )[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically  
  78.   callDomLoadFunctions();
  79.  }
  80.  if (!isDomLoaded) {
  81.   if (typeof doc.addEventListener != UNDEF) {
  82.    doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
  83.   }
  84.   if (ua.ie && ua.win) {
  85.    doc.attachEvent(ON_READY_STATE_CHANGE, function() {
  86.     if (doc.readyState == "complete" ) {
  87.      doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
  88.      callDomLoadFunctions();
  89.     }
  90.    });
  91.    if (win == top) { // if not inside an iframe
  92.     (function(){
  93.      if (isDomLoaded) { return; }
  94.      try {
  95.       doc.documentElement.doScroll("left" );
  96.      }
  97.      catch(e) {
  98.       setTimeout(arguments.callee, 0);
  99.       return;
  100.      }
  101.      callDomLoadFunctions();
  102.     })();
  103.    }
  104.   }
  105.   if (ua.wk) {
  106.    (function(){
  107.     if (isDomLoaded) { return; }
  108.     if (!/loaded|complete/.test(doc.readyState)) {
  109.      setTimeout(arguments.callee, 0);
  110.      return;
  111.     }
  112.     callDomLoadFunctions();
  113.    })();
  114.   }
  115.   addLoadEvent(callDomLoadFunctions);
  116.  }
  117. }();
  118. function callDomLoadFunctions() {
  119.  if (isDomLoaded) { return; }
  120.  try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
  121.   var t = doc.getElementsByTagName("body" )[0].appendChild(createElement("span" ));
  122.   t.parentNode.removeChild(t);
  123.  }
  124.  catch (e) { return; }
  125.  isDomLoaded = true;
  126.  var dl = domLoadFnArr.length;
  127.  for (var i = 0; i < dl; i++) {
  128.   domLoadFnArr[i]();
  129.  }
  130. }
  131. function addDomLoadEvent(fn) {
  132.  if (isDomLoaded) {
  133.   fn();
  134.  }
  135.  else {
  136.   domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
  137.  }
  138. }
  139. /* Cross-browser onload
  140.  - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
  141.  - Will fire an event as soon as a web page including all of its assets are loaded  
  142.  */
  143. function addLoadEvent(fn) {
  144.  if (typeof win.addEventListener != UNDEF) {
  145.   win.addEventListener("load", fn, false);
  146.  }
  147.  else if (typeof doc.addEventListener != UNDEF) {
  148.   doc.addEventListener("load", fn, false);
  149.  }
  150.  else if (typeof win.attachEvent != UNDEF) {
  151.   addListener(win, "onload", fn);
  152.  }
  153.  else if (typeof win.onload == "function" ) {
  154.   var fnOld = win.onload;
  155.   win.onload = function() {
  156.    fnOld();
  157.    fn();
  158.   };
  159.  }
  160.  else {
  161.   win.onload = fn;
  162.  }
  163. }
  164. /* Main function
  165.  - Will preferably execute onDomLoad, otherwise onload (as a fallback)
  166. */
  167. function main() {
  168.  if (plugin) {
  169.   testPlayerVersion();
  170.  }
  171.  else {
  172.   matchVersions();
  173.  }
  174. }
  175. /* Detect the Flash Player version for non-Internet Explorer browsers
  176.  - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
  177.    a. Both release and build numbers can be detected
  178.    b. Avoid wrong descriptions by corrupt installers provided by Adobe
  179.    c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
  180.  - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
  181. */
  182. function testPlayerVersion() {
  183.  var b = doc.getElementsByTagName("body" )[0];
  184.  var o = createElement(OBJECT);
  185.  o.setAttribute("type", FLASH_MIME_TYPE);
  186.  var t = b.appendChild(o);
  187.  if (t) {
  188.   var counter = 0;
  189.   (function(){
  190.    if (typeof t.GetVariable != UNDEF) {
  191.     var d = t.GetVariable("$version" );
  192.     if (d) {
  193.      d = d.split(" " )[1].split("," );
  194.      ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
  195.     }
  196.    }
  197.    else if (counter < 10) {
  198.     counter++;
  199.     setTimeout(arguments.callee, 10);
  200.     return;
  201.    }
  202.    b.removeChild(o);
  203.    t = null;
  204.    matchVersions();
  205.   })();
  206.  }
  207.  else {
  208.   matchVersions();
  209.  }
  210. }
  211. /* Perform Flash Player and SWF version matching; static publishing only
  212. */
  213. function matchVersions() {
  214.  var rl = regObjArr.length;
  215.  if (rl > 0) {
  216.   for (var i = 0; i < rl; i++) { // for each registered object element
  217.    var id = regObjArr[i].id;
  218.    var cb = regObjArr[i].callbackFn;
  219.    var cbObj = {success:false, id:id};
  220.    if (ua.pv[0] > 0) {
  221.     var obj = getElementById(id);
  222.     if (obj) {
  223.      if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
  224.       setVisibility(id, true);
  225.       if (cb) {
  226.        cbObj.success = true;
  227.        cbObj.ref = getObjectById(id);
  228.        cb(cbObj);
  229.       }
  230.      }
  231.      else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
  232.       var att = {};
  233.       att.data = regObjArr[i].expressInstall;
  234.       att.width = obj.getAttribute("width" ) || "0";
  235.       att.height = obj.getAttribute("height" ) || "0";
  236.       if (obj.getAttribute("class" )) { att.styleclass = obj.getAttribute("class" ); }
  237.       if (obj.getAttribute("align" )) { att.align = obj.getAttribute("align" ); }
  238.       // parse HTML object param element's name-value pairs
  239.       var par = {};
  240.       var p = obj.getElementsByTagName("param" );
  241.       var pl = p.length;
  242.       for (var j = 0; j < pl; j++) {
  243.        if (p[j].getAttribute("name" ).toLowerCase() != "movie" ) {
  244.         par[p[j].getAttribute("name" )] = p[j].getAttribute("value" );
  245.        }
  246.       }
  247.       showExpressInstall(att, par, id, cb);
  248.      }
  249.      else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
  250.       displayAltContent(obj);
  251.       if (cb) { cb(cbObj); }
  252.      }
  253.     }
  254.    }
  255.    else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
  256.     setVisibility(id, true);
  257.     if (cb) {
  258.      var o = getObjectById(id); // test whether there is an HTML object element or not
  259.      if (o && typeof o.SetVariable != UNDEF) {
  260.       cbObj.success = true;
  261.       cbObj.ref = o;
  262.      }
  263.      cb(cbObj);
  264.     }
  265.    }
  266.   }
  267.  }
  268. }
  269. function getObjectById(objectIdStr) {
  270.  var r = null;
  271.  var o = getElementById(objectIdStr);
  272.  if (o && o.nodeName == "OBJECT" ) {
  273.   if (typeof o.SetVariable != UNDEF) {
  274.    r = o;
  275.   }
  276.   else {
  277.    var n = o.getElementsByTagName(OBJECT)[0];
  278.    if (n) {
  279.     r = n;
  280.    }
  281.   }
  282.  }
  283.  return r;
  284. }
  285. /* Requirements for Adobe Express Install
  286.  - only one instance can be active at a time
  287.  - fp 6.0.65 or higher
  288.  - Win/Mac OS only
  289.  - no Webkit engines older than version 312
  290. */
  291. function canExpressInstall() {
  292.  return !isExpressInstallActive && hasPlayerVersion("6.0.65" ) && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
  293. }
  294. /* Show the Adobe Express Install dialog
  295.  - Reference: http://www.adobe.com/cfusion/knowl [...] d=6a253b75
  296. */
  297. function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
  298.  isExpressInstallActive = true;
  299.  storedCallbackFn = callbackFn || null;
  300.  storedCallbackObj = {success:false, id:replaceElemIdStr};
  301.  var obj = getElementById(replaceElemIdStr);
  302.  if (obj) {
  303.   if (obj.nodeName == "OBJECT" ) { // static publishing
  304.    storedAltContent = abstractAltContent(obj);
  305.    storedAltContentId = null;
  306.   }
  307.   else { // dynamic publishing
  308.    storedAltContent = obj;
  309.    storedAltContentId = replaceElemIdStr;
  310.   }
  311.   att.id = EXPRESS_INSTALL_ID;
  312.   if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
  313.   if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
  314.   doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
  315.   var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
  316.    fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26" ) + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
  317.   if (typeof par.flashvars != UNDEF) {
  318.    par.flashvars += "&" + fv;
  319.   }
  320.   else {
  321.    par.flashvars = fv;
  322.   }
  323.   // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
  324.   // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  325.   if (ua.ie && ua.win && obj.readyState != 4) {
  326.    var newObj = createElement("div" );
  327.    replaceElemIdStr += "SWFObjectNew";
  328.    newObj.setAttribute("id", replaceElemIdStr);
  329.    obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
  330.    obj.style.display = "none";
  331.    (function(){
  332.     if (obj.readyState == 4) {
  333.      obj.parentNode.removeChild(obj);
  334.     }
  335.     else {
  336.      setTimeout(arguments.callee, 10);
  337.     }
  338.    })();
  339.   }
  340.   createSWF(att, par, replaceElemIdStr);
  341.  }
  342. }
  343. /* Functions to abstract and display alternative content
  344. */
  345. function displayAltContent(obj) {
  346.  if (ua.ie && ua.win && obj.readyState != 4) {
  347.   // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
  348.   // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
  349.   var el = createElement("div" );
  350.   obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
  351.   el.parentNode.replaceChild(abstractAltContent(obj), el);
  352.   obj.style.display = "none";
  353.   (function(){
  354.    if (obj.readyState == 4) {
  355.     obj.parentNode.removeChild(obj);
  356.    }
  357.    else {
  358.     setTimeout(arguments.callee, 10);
  359.    }
  360.   })();
  361.  }
  362.  else {
  363.   obj.parentNode.replaceChild(abstractAltContent(obj), obj);
  364.  }
  365. }
  366. function abstractAltContent(obj) {
  367.  var ac = createElement("div" );
  368.  if (ua.win && ua.ie) {
  369.   ac.innerHTML = obj.innerHTML;
  370.  }
  371.  else {
  372.   var nestedObj = obj.getElementsByTagName(OBJECT)[0];
  373.   if (nestedObj) {
  374.    var c = nestedObj.childNodes;
  375.    if (c) {
  376.     var cl = c.length;
  377.     for (var i = 0; i < cl; i++) {
  378.      if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM" ) && !(c[i].nodeType == 8)) {
  379.       ac.appendChild(c[i].cloneNode(true));
  380.      }
  381.     }
  382.    }
  383.   }
  384.  }
  385.  return ac;
  386. }
  387. /* Cross-browser dynamic SWF creation
  388. */
  389. function createSWF(attObj, parObj, id) {
  390.  var r, el = getElementById(id);
  391.  if (ua.wk && ua.wk < 312) { return r; }
  392.  if (el) {
  393.   if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
  394.    attObj.id = id;
  395.   }
  396.   if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
  397.    var att = "";
  398.    for (var i in attObj) {
  399.     if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
  400.      if (i.toLowerCase() == "data" ) {
  401.       parObj.movie = attObj[i];
  402.      }
  403.      else if (i.toLowerCase() == "styleclass" ) { // 'class' is an ECMA4 reserved keyword
  404.       att += ' class="' + attObj[i] + '"';
  405.      }
  406.      else if (i.toLowerCase() != "classid" ) {
  407.       att += ' ' + i + '="' + attObj[i] + '"';
  408.      }
  409.     }
  410.    }
  411.    var par = "";
  412.    for (var j in parObj) {
  413.     if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
  414.      par += '<param name="' + j + '" value="' + parObj[j] + '" />';
  415.     }
  416.    }
  417.    el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
  418.    objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
  419.    r = getElementById(attObj.id);
  420.   }
  421.   else { // well-behaving browsers
  422.    var o = createElement(OBJECT);
  423.    o.setAttribute("type", FLASH_MIME_TYPE);
  424.    for (var m in attObj) {
  425.     if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
  426.      if (m.toLowerCase() == "styleclass" ) { // 'class' is an ECMA4 reserved keyword
  427.       o.setAttribute("class", attObj[m]);
  428.      }
  429.      else if (m.toLowerCase() != "classid" ) { // filter out IE specific attribute
  430.       o.setAttribute(m, attObj[m]);
  431.      }
  432.     }
  433.    }
  434.    for (var n in parObj) {
  435.     if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie" ) { // filter out prototype additions from other potential libraries and IE specific param element
  436.      createObjParam(o, n, parObj[n]);
  437.     }
  438.    }
  439.    el.parentNode.replaceChild(o, el);
  440.    r = o;
  441.   }
  442.  }
  443.  return r;
  444. }
  445. function createObjParam(el, pName, pValue) {
  446.  var p = createElement("param" );
  447.  p.setAttribute("name", pName);
  448.  p.setAttribute("value", pValue);
  449.  el.appendChild(p);
  450. }
  451. /* Cross-browser SWF removal
  452.  - Especially needed to safely and completely remove a SWF in Internet Explorer
  453. */
  454. function removeSWF(id) {
  455.  var obj = getElementById(id);
  456.  if (obj && obj.nodeName == "OBJECT" ) {
  457.   if (ua.ie && ua.win) {
  458.    obj.style.display = "none";
  459.    (function(){
  460.     if (obj.readyState == 4) {
  461.      removeObjectInIE(id);
  462.     }
  463.     else {
  464.      setTimeout(arguments.callee, 10);
  465.     }
  466.    })();
  467.   }
  468.   else {
  469.    obj.parentNode.removeChild(obj);
  470.   }
  471.  }
  472. }
  473. function removeObjectInIE(id) {
  474.  var obj = getElementById(id);
  475.  if (obj) {
  476.   for (var i in obj) {
  477.    if (typeof obj[i] == "function" ) {
  478.     obj[i] = null;
  479.    }
  480.   }
  481.   obj.parentNode.removeChild(obj);
  482.  }
  483. }
  484. /* Functions to optimize JavaScript compression
  485. */
  486. function getElementById(id) {
  487.  var el = null;
  488.  try {
  489.   el = doc.getElementById(id);
  490.  }
  491.  catch (e) {}
  492.  return el;
  493. }
  494. function createElement(el) {
  495.  return doc.createElement(el);
  496. }
  497. /* Updated attachEvent function for Internet Explorer
  498.  - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
  499. */
  500. function addListener(target, eventType, fn) {
  501.  target.attachEvent(eventType, fn);
  502.  listenersArr[listenersArr.length] = [target, eventType, fn];
  503. }
  504. /* Flash Player and SWF content version matching
  505. */
  506. function hasPlayerVersion(rv) {
  507.  var pv = ua.pv, v = rv.split("." );
  508.  v[0] = parseInt(v[0], 10);
  509.  v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
  510.  v[2] = parseInt(v[2], 10) || 0;
  511.  return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
  512. }
  513. /* Cross-browser dynamic CSS creation
  514.  - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/ar [...] micCSS.php
  515. */
  516. function createCSS(sel, decl, media, newStyle) {
  517.  if (ua.ie && ua.mac) { return; }
  518.  var h = doc.getElementsByTagName("head" )[0];
  519.  if (!h) { return; } // to also support badly authored HTML pages that lack a head element
  520.  var m = (media && typeof media == "string" ) ? media : "screen";
  521.  if (newStyle) {
  522.   dynamicStylesheet = null;
  523.   dynamicStylesheetMedia = null;
  524.  }
  525.  if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
  526.   // create dynamic stylesheet + get a global reference to it
  527.   var s = createElement("style" );
  528.   s.setAttribute("type", "text/css" );
  529.   s.setAttribute("media", m);
  530.   dynamicStylesheet = h.appendChild(s);
  531.   if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
  532.    dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
  533.   }
  534.   dynamicStylesheetMedia = m;
  535.  }
  536.  // add style rule
  537.  if (ua.ie && ua.win) {
  538.   if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
  539.    dynamicStylesheet.addRule(sel, decl);
  540.   }
  541.  }
  542.  else {
  543.   if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
  544.    dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}" ));
  545.   }
  546.  }
  547. }
  548. function setVisibility(id, isVisible) {
  549.  if (!autoHideShow) { return; }
  550.  var v = isVisible ? "visible" : "hidden";
  551.  if (isDomLoaded && getElementById(id)) {
  552.   getElementById(id).style.visibility = v;
  553.  }
  554.  else {
  555.   createCSS("#" + id, "visibility:" + v);
  556.  }
  557. }
  558. /* Filter to avoid XSS attacks
  559. */
  560. function urlEncodeIfNecessary(s) {
  561.  var regex = /[\\\"<>\.;]/;
  562.  var hasBadChars = regex.exec(s) != null;
  563.  return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
  564. }
  565. /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
  566. */
  567. var cleanup = function() {
  568.  if (ua.ie && ua.win) {
  569.   window.attachEvent("onunload", function() {
  570.    // remove listeners to avoid memory leaks
  571.    var ll = listenersArr.length;
  572.    for (var i = 0; i < ll; i++) {
  573.     listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
  574.    }
  575.    // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
  576.    var il = objIdArr.length;
  577.    for (var j = 0; j < il; j++) {
  578.     removeSWF(objIdArr[j]);
  579.    }
  580.    // cleanup library's main closures to avoid memory leaks
  581.    for (var k in ua) {
  582.     ua[k] = null;
  583.    }
  584.    ua = null;
  585.    for (var l in swfobject) {
  586.     swfobject[l] = null;
  587.    }
  588.    swfobject = null;
  589.   });
  590.  }
  591. }();
  592. return {
  593.  /* Public API
  594.   - Reference: http://code.google.com/p/swfobject/wiki/documentation
  595.  */
  596.  registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
  597.   if (ua.w3 && objectIdStr && swfVersionStr) {
  598.    var regObj = {};
  599.    regObj.id = objectIdStr;
  600.    regObj.swfVersion = swfVersionStr;
  601.    regObj.expressInstall = xiSwfUrlStr;
  602.    regObj.callbackFn = callbackFn;
  603.    regObjArr[regObjArr.length] = regObj;
  604.    setVisibility(objectIdStr, false);
  605.   }
  606.   else if (callbackFn) {
  607.    callbackFn({success:false, id:objectIdStr});
  608.   }
  609.  },
  610.  getObjectById: function(objectIdStr) {
  611.   if (ua.w3) {
  612.    return getObjectById(objectIdStr);
  613.   }
  614.  },
  615.  embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
  616.   var callbackObj = {success:false, id:replaceElemIdStr};
  617.   if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
  618.    setVisibility(replaceElemIdStr, false);
  619.    addDomLoadEvent(function() {
  620.     widthStr += ""; // auto-convert to string
  621.     heightStr += "";
  622.     var att = {};
  623.     if (attObj && typeof attObj === OBJECT) {
  624.      for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
  625.       att[i] = attObj[i];
  626.      }
  627.     }
  628.     att.data = swfUrlStr;
  629.     att.width = widthStr;
  630.     att.height = heightStr;
  631.     var par = {};
  632.     if (parObj && typeof parObj === OBJECT) {
  633.      for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
  634.       par[j] = parObj[j];
  635.      }
  636.     }
  637.     if (flashvarsObj && typeof flashvarsObj === OBJECT) {
  638.      for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
  639.       if (typeof par.flashvars != UNDEF) {
  640.        par.flashvars += "&" + k + "=" + flashvarsObj[k];
  641.       }
  642.       else {
  643.        par.flashvars = k + "=" + flashvarsObj[k];
  644.       }
  645.      }
  646.     }
  647.     if (hasPlayerVersion(swfVersionStr)) { // create SWF
  648.      var obj = createSWF(att, par, replaceElemIdStr);
  649.      if (att.id == replaceElemIdStr) {
  650.       setVisibility(replaceElemIdStr, true);
  651.      }
  652.      callbackObj.success = true;
  653.      callbackObj.ref = obj;
  654.     }
  655.     else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
  656.      att.data = xiSwfUrlStr;
  657.      showExpressInstall(att, par, replaceElemIdStr, callbackFn);
  658.      return;
  659.     }
  660.     else { // show alternative content
  661.      setVisibility(replaceElemIdStr, true);
  662.     }
  663.     if (callbackFn) { callbackFn(callbackObj); }
  664.    });
  665.   }
  666.   else if (callbackFn) { callbackFn(callbackObj); }
  667.  },
  668.  switchOffAutoHideShow: function() {
  669.   autoHideShow = false;
  670.  },
  671.  ua: ua,
  672.  getFlashPlayerVersion: function() {
  673.   return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
  674.  },
  675.  hasFlashPlayerVersion: hasPlayerVersion,
  676.  createSWF: function(attObj, parObj, replaceElemIdStr) {
  677.   if (ua.w3) {
  678.    return createSWF(attObj, parObj, replaceElemIdStr);
  679.   }
  680.   else {
  681.    return undefined;
  682.   }
  683.  },
  684.  showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
  685.   if (ua.w3 && canExpressInstall()) {
  686.    showExpressInstall(att, par, replaceElemIdStr, callbackFn);
  687.   }
  688.  },
  689.  removeSWF: function(objElemIdStr) {
  690.   if (ua.w3) {
  691.    removeSWF(objElemIdStr);
  692.   }
  693.  },
  694.  createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
  695.   if (ua.w3) {
  696.    createCSS(selStr, declStr, mediaStr, newStyleBoolean);
  697.   }
  698.  },
  699.  addDomLoadEvent: addDomLoadEvent,
  700.  addLoadEvent: addLoadEvent,
  701.  getQueryParamValue: function(param) {
  702.   var q = doc.location.search || doc.location.hash;
  703.   if (q) {
  704.    if (/\?/.test(q)) { q = q.split("?" )[1]; } // strip question mark
  705.    if (param == null) {
  706.     return urlEncodeIfNecessary(q);
  707.    }
  708.    var pairs = q.split("&" );
  709.    for (var i = 0; i < pairs.length; i++) {
  710.     if (pairs[i].substring(0, pairs[i].indexOf("=" )) == param) {
  711.      return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=" ) + 1)));
  712.     }
  713.    }
  714.   }
  715.   return "";
  716.  },
  717.  // For internal usage only
  718.  expressInstallCallback: function() {
  719.   if (isExpressInstallActive) {
  720.    var obj = getElementById(EXPRESS_INSTALL_ID);
  721.    if (obj && storedAltContent) {
  722.     obj.parentNode.replaceChild(storedAltContent, obj);
  723.     if (storedAltContentId) {
  724.      setVisibility(storedAltContentId, true);
  725.      if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
  726.     }
  727.     if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
  728.    }
  729.    isExpressInstallActive = false;
  730.   }
  731.  }
  732. };
  733. }();


 
Merci d'avance


Message édité par essie le 04-04-2011 à 10:27:31
Reply

Marsh Posté le 04-04-2011 à 10:26:59   

Reply

Marsh Posté le 06-04-2011 à 07:50:03    

Non !
Ça c'est le code source de la librairie swfOject... Tu n'y touches en aucun cas.
C'est au moment de l'instanciation qu'il faut mettre tes paramètres, lis la doc de swfobject sur leur site :
http://code.google.com/p/swfobject [...] r_SWF_with


Message édité par abais le 06-04-2011 à 07:51:21

---------------
Le membre ci-contre n'est pas responsable du message ci-dessus.
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed