Comunidad de diseño web y desarrollo en internet online

Ayuda para modificar script efecto de nieve

Citar            
MensajeEscrito el 31 Oct 2008 11:26 am
Hola, siento postear tan poco, pero os hago saber que uso este foro bastante a menudo.

Ahí va mi duda.

He utilizado el tuto de efecto de nieve de cristalab para la postal navideña de mi empresa. El caso es que la animación empieza automáticamente al iniciar la película y lo que yo quiero es que se active con un botón. Seguro que es una chorrada de fácil, pero no doy para más. ¿Alguien me puede echar un cable?

dejo un link al tutorial:

http://www.cristalab.com/tutoriales/137/efecto-de-nieve-en-flash.html

Por PoorSailor

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 31 Oct 2008 12:41 pm
Lo que se me ocurre (lo he probado y funciona) es que añadas un fotograma mas en la linea de tiempo, en el primero creas un boton (btn_mc) y añades este código:

Código ActionScript :

btn_mc.onRelease = function() {
   createSnow();
   this.gotoAndPlay(2);
};
stop();


Después en el segundo fotograma:

Código ActionScript :

//////////////////////////////////////////////////////////////////
function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}
//////////////////////////////////////////////////////////////////
function moveSnow() {
   if (this.moving) {
      this._y += this.speed;
      this._x += Math.cos(this._y / 10);

      if (this.hitTest(_root.rect_mc.Ice_mc)) {
         this.moving = false;
         this.stopCounter = 0;
      }   
      
      if (this._y > 327){
         removeMovieClip(this);
                  
      }
   } 
   else {
      this.stopCounter++;
      if (this.stopCounter > 500) {
         this.onEnterFrame = null;
         this.removeMovieClip();
      }
   }
}

//////////////////////////////////////////////////////////////////
function createSnow(){
   i = _root.getNextHighestDepth();
   tmp = _root.attachMovie("SnowFlake","snowflake_mc" +i,i);
   tmp._x = randRange(1,550);
   tmp._y = -1;
   tmp._alpha = randRange(50, 100);
   tmp.speed = randRange(1,10);
   tmp._xscale = randRange(70,110);
   tmp._yscale = tmp._xscale;
   tmp.moving = true;
   tmp.onEnterFrame = moveSnow;
}
//////////////////////////////////////////////////////////////////
control_mc.onEnterFrame = function() {
      createSnow();
}
//////////////////////////////////////////////////////////////////


Suerte! :wink:

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 31 Oct 2008 03:23 pm
^^ Hey! muchas gracias... estaba probando a meterlo todo en un clip de pelicula, pero mis conocimientos de action script son bastante limitaditos.

Lo pruebo así.


Gracias mil!!! ^^ ^^ ^^ ^^

Por PoorSailor

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 31 Oct 2008 03:56 pm
Realmente creo que es una chapucilla, pero funcionar funciona :wink:

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari

 

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