Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: OssoH en 9 Septiembre 2010, 21:37 pm



Título: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 9 Septiembre 2010, 21:37 pm
Hola a todos, recurro a vosotros porque llevo dias intentándolo sin éxito y tengo fé en que algún profesional del flash me sacará de dudas. Tengo que decir que mis nociones de flash son muy básicas y es una razon de peso para no haber encontrado la solucion.

Me he descargado este ejemplo CS3: http://www.fladev.com/featured/building-a-fullscreen-background-image-with-as3/
Este ejemplo carga la imagen predefinida dentro de codigo mainclass.as

Código:
	//create variables
private var loader:Loader;
private static const IMAGE_PATH:String = "bg.jpg";

Lo que yo quiero es desde el html index.html pasarle una variable con la url de la imagen que quiero cargar. Esto supongo que se hace con flashvars pero luego en flash no sé como recogerla para cargarla. Al poner la variable _root me dice que no está definida y de ahí no salgo.

Código:
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="index" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="index.swf" />
<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />
<param name="flashvars" value="parametro1=miValor1&parametro2=miValor2"/>
<embed src="index.swf" flashvars="parametro1=miValor1&parametro2=miValor2" quality="high" bgcolor="#ffffff" width="100%" height="100%" name="index" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
</object>

Otra duda que se me plantea es si existe la posibilidad que al cargar el index.hmtl automáticamente sin presionar el boton 'full screen' se abra en pantalla completa (sin la barra de navegador y barra de tareas).


¿Alguien me puede ayudar?

Muchas gracias.




Título: Re: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 9 Septiembre 2010, 23:00 pm
hola, he encontrado otro codigo
http://www.goopal.org/Google-Sites-Working-Tests/flash-embed/flash-lightbox

lo que pasa es que dice bajo lo siguiente :
You can align the Small Image and SWF Embed using Google Sites Embed properties.

Y ademas no me hace un escalado automático de la imagen :(





Título: Re: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 9 Septiembre 2010, 23:54 pm
finalmente me quedo con el siguietne codigo que viene con el fla

http://blog.circlecube.com/2009/03/tutorial/how-to-use-fullscreen-in-as3-stage-display-state-tutorial/


Ahora lo que tengo que conseguir es cargar la imagen usando loadvars.



Título: Re: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 13 Septiembre 2010, 20:56 pm
tengo el siguiente codigo :

Código:
import flash.display.Stage;
import flash.display.StageDisplayState;

//set stage for FBF
stage.align = "TL";
stage.scaleMode = "noScale";

stage.scaleMode = StageScaleMode.NO_SCALE;  // different stageWidth values
//stage.scaleMode = StageScaleMode.EXACT_FIT; // onResize doesn't fire
//stage.scaleMode = StageScaleMode.SHOW_ALL; // onResize doesn't fire
//stage.scaleMode = StageScaleMode.NO_BORDER; // onResize doesn't fire.
//stage.align = StageAlign.TOP_LEFT;


//stage.displayState = StageDisplayState.FULL_SCREEN;
//stage.displayState = StageDisplayState.NORMAL;

//define dynamic aspect ratios
//var picHeight = pic.height / pic.width;
//var picWidth = pic.width / pic.height;

//define dynamic aspect ratios
picHeight = new Object ();
picHeight = pic.height / pic.width;

picWidth = new Object ();
picWidth = pic.width / pic.height;





//add event listener to the stage
stage.addEventListener(Event.RESIZE, sizeListener);

//conditional statement to account for various initial browswer sizes and proportions
function scaleProportional():void {
picHeight = new Object ();
picHeight = pic.height / pic.width;

picWidth = new Object ();
picWidth = pic.width / pic.height;

if ((stage.stageHeight / stage.stageWidth) < picHeight) {
pic.width = stage.stageWidth;
pic.height = picHeight * pic.width;
} else {
pic.height = stage.stageHeight;
pic.width = picWidth * pic.height;
};
}

//center picture on stage
function centerPic():void {
pic.x = stage.stageWidth / 2;
pic.y = stage.stageHeight / 2;
pic.x = Stage.width / 2 - pic.width /2;
pic.y = Stage.height / 2 - pic.height /2;

}

// make listener change picture size and center picture on browser resize
function sizeListener(e:Event):void {
scaleProportional();
centerPic();
  // pic.width = stage.stageWidth;
  // pic.height = stage.stageHeight;
//   pic.x = pic.y = 0

}

//run initial locations and size
//margin_height=400;
scaleProportional();
centerPic();


Mi problema es que al hacer más grande el marco la imagen no se me ajusta proporcionalmente a sus dimensiones y me aparece incompleta.

¿alguien sabe el motivo?
Gracias


Título: Re: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 13 Septiembre 2010, 21:39 pm
ya tengo una parte solucionada

Código:
//set stage for FBF
stage.align = "TL";
stage.scaleMode = "noScale";

stage.scaleMode = StageScaleMode.NO_SCALE;  // different stageWidth values
//stage.scaleMode = StageScaleMode.EXACT_FIT; // onResize doesn't fire
//stage.scaleMode = StageScaleMode.SHOW_ALL; // onResize doesn't fire
//stage.scaleMode = StageScaleMode.NO_BORDER; // onResize doesn't fire.
//stage.align = StageAlign.TOP_LEFT;

// stage.displayState = StageDisplayState.FULL_SCREEN;
//stage.displayState = StageDisplayState.NORMAL;

//define dynamic aspect ratios
//var picHeight = pic.height / pic.width;
//var picWidth = pic.width / pic.height;

//define dynamic aspect ratios
/*picHeight = new Object ();
picHeight = pic.height / pic.width;

picWidth = new Object ();
picWidth = pic.width / pic.height;
*/


//add event listener to the stage
stage.addEventListener(Event.RESIZE, sizeListener);

//conditional statement to account for various initial browswer sizes and proportions
function scaleProportional():void {

    //  figure out width-to-length ratio for both
    var targetRatio:Number = pic.width / pic.height;
    var destRatio:Number = stage.stageWidth / stage.stageHeight;
   
    if(targetRatio > destRatio){
        //  target is landscape, dest is portrait
        pic.width = stage.stageWidth;
        pic.scaleY = pic.scaleX;
    } else if(targetRatio < destRatio){
        //  target is portrait, dest is landscape
        pic.height = stage.stageHeight;
        pic.scaleX = pic.scaleY;
    } else {
        //  both are the same ratio
        pic.width = stage.stageWidth;
        pic.scaleY = pic.scaleX;       
    }
}

//center picture on stage
function centerPic():void {
  pic.x=(stage.stageWidth / 2)  - (pic.width / 2);
  pic.y=(stage.stageHeight / 2)  - (pic.height / 2);
}

// make listener change picture size and center picture on browser resize
function sizeListener(e:Event):void {
scaleProportional();
centerPic();
}

scaleProportional();
centerPic();

Ahora tengo que conseguir pasar un parámetro al swf que sea la url de la imagen y sea cargada en el mc.


Título: Re: pasar parametro a flash para cargar imagen
Publicado por: OssoH en 13 Septiembre 2010, 23:22 pm
solucion :

var s:String = stage.loaderInfo.parameters["url"];