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

flash on 2011-1-30

Get Adobe Flash player
by littlepad 30 Jan 2011
    Embed
/**
 * Copyright littlepad ( http://wonderfl.net/user/littlepad )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mOpM
 */

package {
    import flash.geom.Point;
    import flash.geom.ColorTransform;
    import flash.events.Event;
    import flash.display.PixelSnapping;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private static const PARTICLE_NUM:uint = 1000;
        private static const STAGE_WIDTH:uint = 465;
        private static const STAGE_HEIGHT:uint = 465;
        private var _bmp:Bitmap;
        private var _bmd:BitmapData;
        private var _particles:Array;
        public function FlashTest() {
            init();
        }
        
        private function init():void {
            _particles = new Array();
            _bmd = new BitmapData(STAGE_WIDTH, STAGE_HEIGHT, true, 0xFF000000);
            _bmp = new Bitmap(_bmd, PixelSnapping.NEVER, false);
            addChild(_bmp);
            for(var i:uint = 0; i < PARTICLE_NUM; i++){
                var p:particle = new particle();
                p.x = Math.random() * STAGE_WIDTH;
                p.y = Math.random() * STAGE_HEIGHT;
                _particles.push(p);
            }
            
            addEventListener(Event.ENTER_FRAME, update);
        }
        
        private function update(e:Event):void {
            _bmd.lock();
            _bmd.colorTransform(_bmd.rect, new ColorTransform(1, 1, 1, 1, -30, -30, -10, 0));
            for(var i:uint = 0; i < _particles.length; i++){
                _particles[i].vy = _particles[i].vy + _particles[i].a;
                _particles[i].y = _particles[i].y + _particles[i].vy;
                if( _particles[i].y > 465){
                    _particles[i].x = Math.random() * STAGE_WIDTH;
                    _particles[i].y = Math.random() * STAGE_HEIGHT;
                    _particles[i].vy = 0;
                }
                _bmd.setPixel32(_particles[i].x, _particles[i].y, _particles[i].c);
            }
            _bmd.unlock();
        }

    }
}

internal class particle {
    public var x:Number;
    public var y:Number;
    public var vx:Number;
    public var vy:Number;
    public var a:Number;
    public var c:Number;
    public function particle() {
        x = 0;
        y = 0;
        vx = 0;
        vy = 0;
        a = 0.1;
        c = 0xFFFFFFFF;
    }
}