Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: javascript nakłada się na flasha
Forum PHP.pl > Forum > Po stronie przeglądarki
Vasquez21
Witam.

Mam taki problem:
zrobiłem sobie reklamę w Flashu, która jest wyświetlana na wszystkich podstronach, wywołuję ją tak:

  1. <div id="flashcontent">
  2. </div>


wywoływany jest oczywiście skrypcik, który ładuje flasha.

Następnie na stronie mam wywoływanie zdjęć poprzez skrypcik, który działa w ten sposób, że jakby na tle całej strony powiększa wybraną miniaturkę zdjęcia. Robię to w ten sposób:

  1. <span><a href="costam" rel="CosTamZebySkryptDzialal"><img class="foto" src="costam" /></a></span>


Problem w tym, że kiedy próbuję otworzyć zdjęcie, flash jest NAD wywołanym zdjęciem, przez co go zakrywa...
znajomy poradził mi, żeby to zrobił z-index'em...

więc próbowałem tak, w css'ie:
  1. .zindex2
  2. {
  3. z-index: 2;
  4. }
  5.  
  6. .zindex1
  7. {
  8. z-index: 1;
  9. }

i kod zmieniłem tak:

  1. <div class="zindex1" id="flashcontent">
  2. </div>


  1. <span class="zindex2"><a href="costam" rel="CosTamZebySkryptDzialal"><img class="foto" src="costam" /></a></span>


Pewnie coś pochrzaniłem więc będę wdzięczny za pomoc smile.gif
batman
Miałem podobny problem, z tym że pod baner flash-owy chowało się menu. Rozwiązanie jest bardzo proste. Dodajesz takie coś do parametrów:

  1. <param name="wmode" value="transparent">


A do znacznika <object> : name="wmode"

Jeśli nie zadziała, wówczas wstaw w param, zamiast transparent, opaque. Nie pamiętam dokładnie jak się to robiło. Jutro sprawdzę.

edit

Zgodnie z obietnicą sprawdziłem i wygląda to mniej więcej tak:
  1. <object .....>
  2. <param name="wmode" value="transparent">
  3. ......
  4. <embeded wmode="transparent" ......... >
  5. </embeded>


W miejsce kropek należy wstawić odpowiedni kod html.
babejsza
Nie istnieje taki znacznik jak <embeded/>. Z resztą tak samo jak <embed/>. Jest to niepoprawna konstrukcja i nie powinno się za jej pomocą osadzać flash'y w xhtml'u.

Jeżeli ma być to zrobione poprawnie (znaczy tak, żeby przeszło walidację) to kod powinien wyglądać tak:

  1. <object type="application/x-shockwave-flash" data="plik.swf" width="X" height="Y">
  2. <param name="movie" value="plik.swf" />
  3. <param name="quality" value="High" />
  4. <param name="wmode" value="transparent" />
shpyo
z IE będą problemy (bez względu którego kodu użyjesz). Zainteresuj się swfObject.
Vasquez21
no więc zainteresowałem się i użyłem tego skryptu żeby dodać logo na stronie, ale nie wiem jak ustawić przeźroczystość :/

kodzik:

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


Będę wdzięczny za wskazanie co gdzie wpisać, bo nie znam na tyle js, żeby sobie z tym jakoś poradzić sad.gif
babejsza
to nie w tym pliku masz cokolwiek ustawiać. Ten masz tylko załadować do strony, a jak wyświetlić samego flash'a? No przecież wszystko jest tam opisane: http://blog.deconcept.com/swfobject/

Podpowiedź:

  1. <script type="text/javascript">
  2. var so = new SWFObject("logo.swf", "logo", "100", "100", "6", "#FFF");
  3. so.addParam("quality", "hight");
  4. so.addParam("wmode", "transparent");
  5. so.write("flashcontent");
Vasquez21
dzięki wielkie winksmiley.jpg
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.