Comunidad de diseño web y desarrollo en internet online

Full screen resize pattern picture (AS2)

Citar            
MensajeEscrito el 26 Abr 2009 03:50 pm
Hola, buen dia.. tengo una duda.. hace algunos dias encontre en internet un tutorial de flash para acomodar la pantalla dependiendo de a resolucion de los monitores asi como tambien modificar el tamaño de las imagenes (jpg) dependiendo del mismo, por medio de un .swf y un .AS. Sin embargo este funciona al presionar un boton.

Este es el codigo del AS:

Código :

import gs.TweenLite;
   stop();
   Stage.align="LT"; // this is mandatory

   Stage.scaleMode="noScale";
   
   ancho_minimo = 1024;
   alto_minimo = 600;


   var loader:MovieClipLoader = new MovieClipLoader();

   var loaderListener:Object = new Object();

   // this function is dispatched durring the loadin progress
   loaderListener.onLoadProgress = function(mc:MovieClip, loaded:Number, total:Number):Void
   {
      var percentage:Number = ( loaded / total) * 100;
      load_button.loader_mc.loaderBar_mc._xscale = percentage;
      
      trace('percent loaded ' + Math.round(percentage) +' % ');
   }
   
   
   // this function is dispatched when the loading process starts
   loaderListener.onLoadStart = function(mc:MovieClip)
   {
      trace('load started');
   }
   
   
   // this function is dispatched when the loadin process is finished.
   loaderListener.onLoadInit = function(mc:MovieClip)
   {
      trace('Finisihed loading image inside ' + mc);
      
      // after we finish loading the image we hide the button , which also hides the loader , because the loader is in the button instance.
      load_button._visible = false;
   
      // also when the image is loaded, set the size of the image to fill in the whole screen
      // pass the mc as the parameter for the funcition
      setBgSize(mc);
   }
   
   
   // add the loaderListener to the MovieClipLoader instance .
   loader.addListener(loaderListener);
   
   load_button.onPress = function()
   {
      // when load_button is pressed , tell the loader to load the image in imageHolder mc.
      [b]loader.loadClip('bg.swf',picHolder_mc);[/b]      
   }
   
   
   //FUNCITON TO SCALE ANY MOVIE CLIP TO FIT THE WHOLE SCREEN
   // scales the mc proportionally to fit full screen 
   function setBgSize(mc:MovieClip) { // pass in the mc to be scaled
      //trace('setBgsize called ');
      if (mc._width==0 || mc._height == 0) return;

      var imageRatio:Number = mc._width/mc._height;
      var stageRatio:Number = Stage.width/Stage.height;
      if (stageRatio>=imageRatio) {
         // match image width and adjust height to fit
         mc._width = Stage.width;
         mc._height = Stage.width/imageRatio;
      } else {
         // match image height and adjust width to fit
         mc._height = Stage.height;
         mc._width = Stage.height*imageRatio;
      }
   }
   

   
   // listener that will listen to the onResize event that is fired when the stage is resized
   var stageListener:Object = new Object();
   
   stageListener.onResize = function()
   {
      
      // everytime the stage is resized , set the size of the image , which is held in the picHolder_mc
      setBgSize(picHolder_mc);
      
   }
   
   // add the listener to the stage instance.
   Stage.addListener(stageListener);


Lo que me gustaria es que funcionara sin necesidad de oprimir el boton y cargando elementos de mi biblioteca. Alguien me podria decir, por favor?

Gracias!

Por afxoe

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 22 Oct 2009 08:52 pm
Hola que tal, Yo estoy interesado en hacer algo parecido, si me dices donde puedo descargar el archivo del tutorial estaria encantado de ayudarte, esque asi solo con el codigo no se si seia capaz de armar el ejemplo

un saludo

Por leviatan2

7 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.