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

entropy( type space key )

space key to on off wall
Get Adobe Flash player
by randomizer 23 Apr 2011
/**
 * Copyright randomizer ( http://wonderfl.net/user/randomizer )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4cRG
 */

package{
    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;

    public class test extends Sprite {        
        public var particles:Array = new Array();
        public var onoffwall:int = 1;

        public function test() {
            var i:int;

            for( i = 0 ; i < 500 ; i++ ) {
                particles[i] = new particle();

            }

            stage.addEventListener( KeyboardEvent.KEY_DOWN , onKeyDown );
            addEventListener( Event.ENTER_FRAME , onIdle );
        }

        public function onIdle( e:Event ) : void {
            var g:Graphics;
            var i:int;

            for( i = 0 ; i < 500 ; i++ ) {
                particles[i].move( onoffwall );
            }

            g = graphics;
            
            g.clear();
            g.lineStyle( 1 , 0 );

            if( onoffwall == 1 ) {
                g.moveTo( 232 , 10 );
                g.lineTo( 232 , 210 );
            }

            g.drawRect( 32 , 10 , 400 , 200 );

            for( i = 0 ; i < 500 ; i++ ) {
                g.drawEllipse( int(particles[i].x) , int(particles[i].y) , 1 , 1 );
            }
        }

        public function onKeyDown( e:KeyboardEvent ) : void {
            switch( e.keyCode ) {
            case Keyboard.SPACE:
                onoffwall = ( onoffwall == 0 ? 1 : 0 );
                break;
            }
        }
    }
}

class particle{
    public var x:Number;
    public var y:Number;
    public var vx:Number;
    public var vy:Number;

    public function particle() {
        x = Math.random()*195.0+37.0;
        y = Math.random()*190.0+10.0;
        vx = (Math.random()*4.0+1.0)*( int(Math.floor(Math.random()*2.0)) == 1 ? -1.0 : 1.0 );
        vy = (Math.random()*4.0+1.0)*( int(Math.floor(Math.random()*2.0)) == 1 ? -1.0 : 1.0 );
    }

    public function move( w:int ) : void {
        var lr:int;

        if( x <= 232.0 ) {
            lr = 1;
        } else {
            lr = 0;
        }

        x += vx;
        y += vy;

        if( w ) {
            if( lr ) {
                if( x > 232.0 ) {
                    x = 232.0;
                    vx = vx*(-1.0);
                }
            } else {
                if( x <= 232.0 ) {
                    x = 233.0;
                    vx = vx*(-1.0);
                }
            }
        }

        if( x < 32.0 ) {
            x = 32.0;
            vx = vx*(-1.0);
        }
        if( x > 432.0 ) {
            x = 432.0;
            vx = vx*(-1.0);
        }
        if( y < 10.0 ) {
            y = 10.0;
            vy = vy*(-1.0);
        }
        if( y > 210.0 ) {
            y = 210.0;
            vy = vy*(-1.0);
        }
    }
}