In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Blue Cascade

simple AS3 falling particle system
:D hope u enjoy it
Get Adobe Flash player
by Miki_vanilla 08 Sep 2010
    Embed
/**
 * Copyright Miki_vanilla ( http://wonderfl.net/user/Miki_vanilla )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4gtC
 */

//thanks for your teachings. . .
package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    import flash.filters.GlowFilter;
    import flash.display.BitmapData;
    import flash.filters.DisplacementMapFilter;
    import flash.geom.Point;
    import flash.text.TextField;
    import flash.display.*;
    import flash.events.MouseEvent;
    [SWF(backgroundColor = "#000000",width = "465",height = "465",frameRate = "30")]
    public class cascade extends Sprite
    {
        public var part:Parts;
        public var part2:Parts;
        public var total:Number = new Number(80);
        public var tamaño:Number = new Number(30);
        public var base:Number = new Number(stage.stageWidth);
        public var altura:Number = new Number(stage.stageHeight);
        public var distanciaB:Number = new Number(base / total);
        public var distanciA:Number = new Number(altura / total);
        public var cont:Sprite = new Sprite();

        public function cascade()
        {
            cont.x = 0;
            cont.y = 90;
            init();
        }
        public function init()
        {
            addChild(cont);
            for (var i:uint=0; i<total; i++)
            {
                part = new Parts();
                part2 = new Parts();
                part2.graphics.beginFill(0x33FFFF);
                part2.graphics.drawCircle(distanciaB * i,altura -410,aleatorio(1,tamaño));
                part2.graphics.endFill();
                part2.blendMode = BlendMode.ADD;
                part2.cacheAsBitmap = true;
                part2.filters = [new BlurFilter(10,10)];
                part2.z = aleatorio(0,500);
                cont.addChild(part2);

                part.graphics.beginFill(0x22AAFF);
                part.graphics.drawCircle(distanciaB * i,altura -410,aleatorio(1,tamaño));
                part.graphics.endFill();
                part.cacheAsBitmap = true;
                part.blendMode = BlendMode.ADD;
                part.filters = [new BlurFilter(10,10)];
                part.z = aleatorio(0,500);
                cont.addChild(part);

                part.Xvel = aleatorio(-10,10);
                part.Yvel = aleatorio(-20,20);
                part.Zvel = aleatorio(-50,50);
                part.fade = .003;
                part.Gravedad = 0.9;
                part.GrowX = part.GrowY = part.GrowZ = 1.2;

                part2.Xvel = aleatorio(-10,10);
                part2.Yvel = aleatorio(-20,20);
                part2.Zvel = aleatorio(-50,50);
                part2.fade = .003;
                part2.Gravedad = 0.9;
                part2.GrowX = part2.GrowY = part2.GrowZ = 1.10;

                part.addEventListener(Event.ENTER_FRAME, efr);
                part2.addEventListener(Event.ENTER_FRAME, efr);
            }


        }
        public function efr(e:Event):void
        {
            e.target.Update();

            if (e.target.y > 50)
            {
                e.target.y = 0;
                e.target.Yvel = aleatorio(-20,20);
                e.target.scaleY = 1;
            }
            if (e.target.x < base)
            {
                e.target.x = 0;
                e.target.Xvel = aleatorio(-20,20);
                e.target.scaleX = 1;
            }
            if (e.target.z < 1000)
            {
                e.target.z = 0;
                e.target.Zvel = aleatorio(-20,20);
                e.target.scaleZ = 1;
            }
            if (e.target.alpha <= 0)
            {
                e.target.alpha = 1;
            }
        }
        public function aleatorio(min:Number, max:Number)
        {
            return Math.random()*(max-min)+min;
        }

    }

}

//////////////////////////////""""""""""""""PARTS CLASS""""""""""/////////////////////
import flash.display.*;

class Parts extends Sprite {;

public var Xvel:Number;
public var Yvel:Number;
public var Zvel:Number;
public var Gravedad:Number;
public var Friction:Number;
public var GrowX:Number;
public var GrowY:Number;
public var GrowZ:Number;
public var fade:Number;

public function Parts()
{
    Xvel = 0;
    Yvel = 0;
    Gravedad= 0;
    Friction= 1;
    GrowX= 1;
    GrowY= 1;
    GrowZ= 1;
    fade= 1;
}
public function Update():void
{
    Xvel *= Friction;
    Yvel *= Friction;
    Yvel+= Gravedad;
    this.x += Xvel;
    this.y += Yvel;
    this.z += Zvel;
    this.scaleX *= GrowX;
    this.scaleY *= GrowY;
    this.scaleZ *= GrowZ;
    this.alpha*= fade;
}
}