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

Ukiuki Library - speed test

Get Adobe Flash player
by shohei909 16 Dec 2010
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vINE
 */

package {
    import flash.geom.ColorTransform;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    import net.hires.debug.Stats;
    
    import org.libspark.ukiuki.Ukiuki;
    import org.libspark.ukiuki.ease.Circ;
    
    [SWF(frameRate=60)]
    public class FlashTest extends Sprite {
        private var first:Particle;
        private var num:uint = 30000;
        private const W:int = 465;
        private const H:int = 465;
        private var bitmapData:BitmapData = new BitmapData( W, H, false, 0 ); 
        private var colorTransform:ColorTransform = new ColorTransform( 0.9, 0.8, 0.8 ); 
        
        function FlashTest() {
            // write as3 code here..
            addChild( new Bitmap(bitmapData) )
            addChild( new Stats() );
            addEventListener( "exitFrame", onFrame );
            stage.quality = "low";
            
            var p:Particle;
            for( var i:uint = 0; i < num; i++ ){
                p = new Particle( Math.random()*W, Math.random() * H , p )
                Ukiuki.tween( p, { y: H + 10 }, { time:1+50*Math.random(), repeat: -1, ease:Circ.IN } )
            }
            first = p;
        }
        
        private function onFrame( e:Event ):void{
            var p:Particle = first;
            var b:BitmapData = bitmapData;
            b.lock();
            while( p = p.next ){
                b.setPixel( p.x, p.y, 0xFFFFFF )
            }
            b.colorTransform( b.rect, colorTransform )
            b.unlock();
        }
    }
}

final class Particle{
    public var x:Number;
    public var y:Number;
    public var next:Particle;
    function Particle( x:Number, y:Number, next:Particle ){
        this.x = x; this.y = y; this.next = next;
    }
}