Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/06/2007, 06:56
baires3k
 
Fecha de Ingreso: septiembre-2003
Mensajes: 92
Antigüedad: 20 años, 6 meses
Puntos: 0
cambiar el tamaño del canvas (escenario) de flash por medio de javascript

Buenas, tengo una duda, he logrado poder cambiar el tamaño del escenario de flash dependiendo de mis necesidades mediante javascript, el problema surge que esto funciona en mozilla y explorer 7, pero no en el explorer 6 (que lamentablemente, sigue siendo el màs popular). Si quieren ver la web, es esta: http://www.estudiomaniac.com.ar/maniac
mediante el menu de la izquierda pueden cambiar los contenidos. y el tamaño se va adaptando.

Acà les paso el codigo por si alguien lo necesita:

HTML
====
Head:
Código:
<script type="text/javascript" src="flash_resize.js"></script>
Body:
Código:
<div align="left">
  <div id="flashid" style="width:870px; height:1080px;">
    <script type="text/javascript">
      e = canResizeFlash();
      document.write('<object data="index.swf" width="100%" height="100%" type="application/x-shockwave-flash">');
      document.write('  <param name="movie" value="index.swf" />');
      document.write('  <param name="FlashVars" value="allowResize='+e+'" />');
      document.write('  Flash Movie With Resizing Content');
      document.write('</object>');
    </script>
    <noscript>Javascript must be enabled to view Flash movie</noscript>
  </div>
</div>
JAVASCRIPT: (flash_resize.js)
=========
Código:
/* 
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not. 
*/
function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
}
function setFlashHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";		
}
function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}
FLASH
=====
En el primer frame del INDEX.fla
Código:
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.showMenu = false;
Y en cada boton, dependiendo del tamaño deseado:
Código:
getURL("javascript:setFlashHeight('flashid', 2200)");

Bueno, ahi va para que lo puedan chequear y usar si lo necesitan.

Ahora bien, alguien me da una mano para poder adaptarlo a Internet Explorer 6 ?