SWFObject.hx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package js;
  2. extern class SWFObject {
  3. function new( swf : String, id : String, width : Int, height : Int, ver : String, color : String /*...*/ ) : Void;
  4. function addParam( param : String, value : String ) : Void;
  5. function getSWFHTML() : String;
  6. function write( elementId : String ) : Bool;
  7. function addVariable( param : String, value : String ) : Void;
  8. function setAttribute( id : String, value : String ) : Void;
  9. /* Notes : to embed SWF object, it is only needed to copy/paste the .js and replace \ by \\ */
  10. private static function __init__() : Void untyped {
  11. /**
  12. * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
  13. *
  14. * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
  15. * http://www.opensource.org/licenses/mit-license.php
  16. *
  17. * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
  18. * legal reasons.
  19. */
  20. __js__('
  21. if(typeof deconcept=="undefined"){var deconcept=new Object();}
  22. if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
  23. if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
  24. deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
  25. this.DETECT_KEY=_b?_b:"detectflash";
  26. this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
  27. this.params=new Object();
  28. this.variables=new Object();
  29. this.attributes=new Array();
  30. if(_1){this.setAttribute("swf",_1);}
  31. if(id){this.setAttribute("id",id);}
  32. if(w){this.setAttribute("width",w);}
  33. if(h){this.setAttribute("height",h);}
  34. if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
  35. this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
  36. if(c){this.addParam("bgcolor",c);}
  37. var q=_8?_8:"high";
  38. this.addParam("quality",q);
  39. this.setAttribute("useExpressInstall",_7);
  40. this.setAttribute("doExpressInstall",false);
  41. var _d=(_9)?_9:window.location;
  42. this.setAttribute("xiRedirectUrl",_d);
  43. this.setAttribute("redirectUrl","");
  44. if(_a){this.setAttribute("redirectUrl",_a);}};
  45. deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
  46. this.attributes[_e]=_f;
  47. },getAttribute:function(_10){
  48. return this.attributes[_10];
  49. },addParam:function(_11,_12){
  50. this.params[_11]=_12;
  51. },getParams:function(){
  52. return this.params;
  53. },addVariable:function(_13,_14){
  54. this.variables[_13]=_14;
  55. },getVariable:function(_15){
  56. return this.variables[_15];
  57. },getVariables:function(){
  58. return this.variables;
  59. },getVariablePairs:function(){
  60. var _16=new Array();
  61. var key;
  62. var _18=this.getVariables();
  63. for(key in _18){_16.push(key+"="+_18[key]);}
  64. return _16;},getSWFHTML:function(){var _19="";
  65. if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
  66. if(this.getAttribute("doExpressInstall")){
  67. this.addVariable("MMplayerType","PlugIn");}
  68. _19="<embed type=\\"application/x-shockwave-flash\\" src=\\""+this.getAttribute("swf")+"\\" width=\\""+this.getAttribute("width")+"\\" height=\\""+this.getAttribute("height")+"\\"";
  69. _19+=" id=\\""+this.getAttribute("id")+"\\" name=\\""+this.getAttribute("id")+"\\" ";
  70. var _1a=this.getParams();
  71. for(var key in _1a){_19+=[key]+"=\\""+_1a[key]+"\\" ";}
  72. var _1c=this.getVariablePairs().join("&");
  73. if(_1c.length>0){_19+="flashvars=\\""+_1c+"\\"";}_19+="/>";
  74. }else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
  75. _19="<object id=\\""+this.getAttribute("id")+"\\" classid=\\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\\" width=\\""+this.getAttribute("width")+"\\" height=\\""+this.getAttribute("height")+"\\">";
  76. _19+="<param name=\\"movie\\" value=\\""+this.getAttribute("swf")+"\\" />";
  77. var _1d=this.getParams();
  78. for(var key in _1d){_19+="<param name=\\""+key+"\\" value=\\""+_1d[key]+"\\" />";}
  79. var _1f=this.getVariablePairs().join("&");
  80. if(_1f.length>0){_19+="<param name=\\"flashvars\\" value=\\""+_1f+"\\" />";}_19+="</object>";}
  81. return _19;
  82. },write:function(_20){
  83. if(this.getAttribute("useExpressInstall")){
  84. var _21=new deconcept.PlayerVersion([6,0,65]);
  85. if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
  86. this.setAttribute("doExpressInstall",true);
  87. this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
  88. document.title=document.title.slice(0,47)+" - Flash Player Installation";
  89. this.addVariable("MMdoctitle",document.title);}}
  90. if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
  91. var n=(typeof _20=="string")?document.getElementById(_20):_20;
  92. n.innerHTML=this.getSWFHTML();return true;
  93. }else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
  94. return false;}};
  95. deconcept.SWFObjectUtil.getPlayerVersion=function(){
  96. var _23=new deconcept.PlayerVersion([0,0,0]);
  97. if(navigator.plugins&&navigator.mimeTypes.length){
  98. var x=navigator.plugins["Shockwave Flash"];
  99. if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\\s)+/,"").replace(/(\\s+r|\\s+b[0-9]+)/,".").split("."));}
  100. }else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
  101. catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  102. _23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
  103. catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
  104. catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
  105. return _23;};
  106. deconcept.PlayerVersion=function(_27){
  107. this.major=_27[0]!=null?parseInt(_27[0]):0;
  108. this.minor=_27[1]!=null?parseInt(_27[1]):0;
  109. this.rev=_27[2]!=null?parseInt(_27[2]):0;
  110. };
  111. deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
  112. if(this.major<fv.major){return false;}
  113. if(this.major>fv.major){return true;}
  114. if(this.minor<fv.minor){return false;}
  115. if(this.minor>fv.minor){return true;}
  116. if(this.rev<fv.rev){
  117. return false;
  118. }return true;};
  119. deconcept.util={getRequestParameter:function(_29){
  120. var q=document.location.search||document.location.hash;
  121. if(q){var _2b=q.substring(1).split("&");
  122. for(var i=0;i<_2b.length;i++){
  123. if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
  124. return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
  125. return "";}};
  126. deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
  127. var _2d=document.getElementsByTagName("OBJECT");
  128. for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
  129. if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
  130. deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
  131. __flash_savedUnloadHandler=function(){};
  132. if(typeof window.onunload=="function"){
  133. var _30=window.onunload;
  134. window.onunload=function(){
  135. deconcept.SWFObjectUtil.cleanupSWFs();_30();};
  136. }else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
  137. if(typeof window.onbeforeunload=="function"){
  138. var oldBeforeUnload=window.onbeforeunload;
  139. window.onbeforeunload=function(){
  140. deconcept.SWFObjectUtil.prepUnload();
  141. oldBeforeUnload();};
  142. }else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
  143. if(Array.prototype.push==null){
  144. Array.prototype.push=function(_31){
  145. this[this.length]=_31;
  146. return this.length;};}
  147. ');
  148. js.SWFObject = deconcept.SWFObject;
  149. }
  150. }