Ok, me lo merezco por bocón.
Ya encontré la clase que había armado. Sigue paso a paso esto:
- crea la carpeta com/lynda/particles debajo de tu fla
- dentro mete la clase Particles (que está en el Post del confetti)
- y también mete la clase que pongo a continuación:
Código ActionScript :
package com.lynda.particles
{
import flash.display.MovieClip;
import com.lynda.particles.Particle;
import flash.events.Event;
import flash.geom.ColorTransform;
/**
* Efecto confetti
*/
public class EfectoConfetti extends MovieClip
{
private var numOfParticles:uint=10;
private var numOfParticles2:uint=40;
private var particles_ary:Array=[];
private var particles2_ary:Array=[];
private var maxVelocity:Number=8;
private var minVelocity:Number=1;
private var maxVelocity2:Number=5;
private var minVelocity2:Number = 1;
//Hay que incluir los MC en la biblioteca, sino error
function EfectoConfetti() {
addEventListener(Event.ENTER_FRAME, updateStage);
addEventListener(Event.ENTER_FRAME, updateStage2);
}
public function kill():void {
removeEventListener(Event.ENTER_FRAME, updateStage);
removeEventListener(Event.ENTER_FRAME, updateStage2);
}
private function updateStage(event:Event):void {
if (particles_ary.length<numOfParticles) {
var moveAsset2:MoveAsset2 = new MoveAsset2;
var c:ColorTransform = new ColorTransform();
c.color = (Math.random() * 0xFFFFFF);
addChild(moveAsset2);
moveAsset2.ribbon_mc.ribbon_mc.color_mc.transform.colorTransform = c;
moveAsset2.yVelocity = Math.floor(Math.random() * (maxVelocity - minVelocity)) + minVelocity;
moveAsset2.x = Math.floor(Math.random() * (((stage.stageWidth - (moveAsset2.width))) - (moveAsset2.width))) + moveAsset2.width;
particles_ary.push(moveAsset2);
}
for (var i:uint = 0; i < particles_ary.length; i++) {
var particle:MoveAsset2=particles_ary[i];
c = new ColorTransform();
c.color = (Math.random() * 0xFFFFFF);
particles_ary[i].update();
if (particle.y>stage.stageHeight+particle.height/2) {
particle.yVelocity = Math.floor(Math.random() * (maxVelocity - minVelocity)) + minVelocity;
particle.x = Math.floor(Math.random() * ((stage.stageWidth - (particle.width)) - (particle.width))) + (particle.width);
particle.y=0;
particle.scaleY = particle.scaleX = Math.floor(Math.random() * (3 - 0) + 0);;
particle.ribbon_mc.ribbon_mc.color_mc.transform.colorTransform = c;
if (particle.scaleX||particle.scaleY>1){
particle.alpha = Math.random()* .8 + .2;
}
}
}
}
private function updateStage2(event:Event):void {
if (particles2_ary.length<numOfParticles2) {
var moveAsset1:MoveAsset1 = new MoveAsset1;
var c:ColorTransform = new ColorTransform();
c.color = (Math.random() * 0xFFFFFF);
addChild(moveAsset1);
moveAsset1.confetti_mc.color_mc.transform.colorTransform = c;
moveAsset1.yVelocity = Math.floor(Math.random() * (maxVelocity2 - minVelocity2)) + minVelocity2;
moveAsset1.x = Math.floor(Math.random() * (((stage.stageWidth - (moveAsset1.width))) - (moveAsset1.width))) + moveAsset1.width;
particles2_ary.push(moveAsset1);
}
for (var i:uint = 0; i < particles2_ary.length; i++) {
var particle1:MoveAsset1=particles2_ary[i];
c = new ColorTransform();
c.color = (Math.random() * 0xFFFFFF);
particles2_ary[i].update();
if (particle1.y>stage.stageHeight+particle1.height/2) {
particle1.yVelocity = Math.floor(Math.random() * (maxVelocity2 - minVelocity2)) + minVelocity2;
particle1.x = Math.floor(Math.random() * ((stage.stageWidth - (particle1.width)) - (particle1.width))) + (particle1.width);
particle1.y=0;
particle1.scaleY = particle1.scaleX = Math.floor(Math.random() * (3 - 0) + 0);;
particle1.confetti_mc.color_mc.transform.colorTransform = c;
if (particle1.scaleX||particle1.scaleY>1){
particle1.alpha = Math.random()* .8 + .2;
}
}
}
}
}
}
En el fla, unico frame, línea de tiempo pon:
Código ActionScript :
import com.lynda.particles.EfectoConfetti;
addChild(new EfectoConfetti())
Jorge