Comunidad de diseño web y desarrollo en internet online

problema con nieve que no se detiene

Citar            
MensajeEscrito el 28 May 2007 03:15 am
alguien podria ayudarme??
es el primer umm.. tema que escribo, espero que este bien donde lo puse, la verdad necesito saber como parar la nieve puse un frame y le puse las acciones para que callera nieve, pero duratne toda la presentacion sigue la nieve callendo!!

mi accion script es este:



Código :

amount = 300;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; i<amount; i++) {
            thisnieve = this.attachMovie("flake", "flake"+i, i);
            with (thisnieve) {
                        _x = Math.random()*mWidth;
                        _y = Math.random()*mHeight;
                        _xscale = _yscale=_alpha=50+Math.random()*50;
            }
            thisnieve.yspeed = Math.random()*2.5+1;
            thisnieve.onEnterFrame = function() {
                        this._y += this.yspeed;
                        if (this._y>=mHeight) {
                                   this._y = -10;
                                   this._x = -10+Math.random()*mWidth;
                        }
                        if (this._x>=mWidth || this._x<=0) {
                                   this._y = -10;
                                   this._x = -10+Math.random()*mWidth;
                        }
            };
}


espero sepan como hacer que pare :?

Por zaphyro

1 de clabLevel



Genero:Femenino  

msie7
Citar            
MensajeEscrito el 28 May 2007 09:45 am
Hasta que no termine el bucle (i<amount), nada puedes hacer.

Igual deberías implementarlo con un while, cuya condición sea:

Código :

while (i<amount && !fin){
//acciones
i++;
}
De esta forma, con declarar "fin" como "true", saldrá del bucle.
U_U

Por Bleend

Claber

3385 de clabLevel

10 tutoriales
4 articulos

Genero:Masculino   Héroes

Barcelona

firefox
Citar            
MensajeEscrito el 28 May 2007 09:46 am

Código :


amount = 100;
mWidth = Stage.width;
mHeight = Stage.height;

function CreaNieve() {

   for (var i = 0; i<amount; i++) {
            thisnieve = this.attachMovie("flake", "flake"+i, i);
            with (thisnieve) {
                        _x = Math.random()*mWidth;
                        _y = Math.random()*mHeight;
                        _xscale = _yscale=_alpha=50+Math.random()*50;
            }
            thisnieve.yspeed = Math.random()*2.5+1;
            thisnieve.onEnterFrame = function() {
                        this._y += this.yspeed;
                        if (this._y>=mHeight) {
                                   this._y = -10;
                                   this._x = -10+Math.random()*mWidth;
                        }
                        if (this._x>=mWidth || this._x<=0) {
                                   this._y = -10;
                                   this._x = -10+Math.random()*mWidth;
                        }
            };
   }
}

CreaNieve();




Luego te creas un boton con el siguiente código, o simplemente lo colocas en tu flash donde más te convenga para parar la nieve.

Código :

on (click) {
   if (this.parado != true) {
      for (var i = 0; i<_parent.amount; i++) {
         eval("_parent.flake"+i).onEnterFrame = null;
      }
      this.parado = true;
   } else {
      _parent.CreaNieve();
      this.parado = false;      
   }
}

[/quote][/code]

Por sr.pino

24 de clabLevel



 

Elche - España

firefox
Citar            
MensajeEscrito el 28 May 2007 07:43 pm
en espaniol?? por que yo nomas copie el codigo y no entiendo nada gracias ^^

Por zaphyro

1 de clabLevel



Genero:Femenino  

msie7
Citar            
MensajeEscrito el 17 Oct 2007 01:53 pm
he probado la última opción, pero no puedo parar la nieve, alguna solución?

Por loresaff

3 de clabLevel



Genero:Femenino  

msie7

 

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