En este Tip muestro como hacer el clásico efecto de nevada en ActionScript 3. Este tip, es más una traducción de un tutorial que yo vi hace tiempo.
// Tamaños pantalla
var width2 = stage.stageWidth;
var height2 = stage.stageHeight;
// Máximo tamaño copos y cantidad
var max_tamaño = 10;
var copos = 100;
function init () {
for (var i:Number=0; i<copos; i++) {
var t:snow=new snow();
addChild(t);
t.alpha = 0.2+Math.random()*0.6;
t.x = -(width2/2)+Math.random()*(1.5*width2);
t.y = -(height2/2)+Math.random()*(1.5*height2);
t.scaleX = t.scaleY=0.5+Math.random()*(max_tamaño*0.1);
t.k = 1+Math.random()*2;
t.viento = -1.5+Math.random()*(1.4*3);
t.addEventListener(Event.ENTER_FRAME, mover);
}
};
function mover(e:*){
e.target.y += e.target.k;
e.target.x += e.target.viento;
if (e.target.y>height2+10) {
e.target.y = -20;
}
if (e.target.x>width2+20) {
e.target.x = -(width2/2)+Math.random()*(1.5*width2);
e.target.y = -20;
}
else if (e.target.x<-20) {
e.target.x = -(width2/2)+Math.random()*(1.5*width2);
e.target.y = -20;
}
}
init();
Ok, para que esto funcione solamente creen un mc, que sea un punto blanco difuminado (Blur) o un circulo que tenga un degradado radial de blanco al centro y transparente al rededor.
Para que represente un copo de nieve.
Luego en la Biblioteca, le das clic derecho seleccionas Linkage y en Class, escribe snow.
Simple, pero bonito.
Recomiendo ocupar fondo oscuro.
Para el ejemplo, el tamaño máximo de los copos es 5 y la cantidad máxima de copos es 150.
:!!: