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

forked from: forked from: hyperdiscosquares

Messing around
/**
 * Copyright 0xABCDEF ( http://wonderfl.net/user/0xABCDEF )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ajGG
 */

// forked from PrettyMuchBryce's forked from: hyperdiscosquares
// forked from PrettyMuchBryce's hyperdiscosquares
package {
    //Messing around
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.Bitmap;
    import flash.events.MouseEvent;
    import flash.display.BitmapData;
   [ SWF (width = '400', height = '500', backgroundColor = '0x000000', frameRate = '60')]
    public class FlashTest extends Sprite {
        private var _squares:Vector.<Square>;
        private var _squares2:Vector.<Square>;
        private var _buffer:Bitmap;
        private var _subBuffer:Bitmap;
        private var _tick:int = 0;
        private const _tickMax:int = 5;
        public function FlashTest() {
            _buffer = new Bitmap(new BitmapData(500,500,false,0x0),"auto",false);
            _subBuffer = new Bitmap(new BitmapData(500,500,false,0x0),"auto",false);
            _squares = new Vector.<Square>(100);
            _squares2 = new Vector.<Square>( 400,true );
            addEventListener(Event.ENTER_FRAME,update);
            stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
            addChild(_buffer);
            _buffer.x=-50;
            for (var i:int = 0; i < 500/50; i++) {
                for (var j:int = 0; j < 500/50; j++) {
                    _squares[(i*10)+j]=new Square(i*50,j*50);
                }
            }
            for( i=0; i<20; ++i )
            {
                for( j=0; j<20; ++j )
                {
                    _squares2[ ( i*20 )+j ] = new Square( i*50/2, j*50/2, 50/2, 50/2 );
                }
            }
        }
        public function update(e:Event):void {
            _tick++;
            if (_tick > _tickMax) {
                for (var i:int=0; i < 100; i++) {
                    _squares[i].colorize();
                    _squares[i].render(_buffer.bitmapData);
                }
                for( i=0; i<400; ++i )
                {
                    _squares2[ i ].colorize();
                    _squares2[ i ].render( _subBuffer.bitmapData );
                }
                _buffer.bitmapData.draw( _subBuffer, null, null, "overlay" );
                _tick = 0;
            }
        }
        public function onMouseMove(e:MouseEvent):void {
            //_squares[0].setScale(2);
            _squares[(Math.ceil(stage.mouseX/50)*10)+Math.floor(stage.mouseY/50)].setColor(0xFF0000);
            _squares[(Math.ceil(stage.mouseX/50)*10)+Math.floor(stage.mouseY/50)].render(_buffer.bitmapData);
            _squares2[(Math.ceil(stage.mouseX/(50/2))*20)+Math.floor(stage.mouseY/(50/2))].setColor(0xFF0000);
            _squares2[(Math.ceil(stage.mouseX/(50/2))*20)+Math.floor(stage.mouseY/(50/2))].render(_buffer.bitmapData);
        }

    }
}
import flash.display.AVM1Movie;
import flash.display.Shape;
import flash.geom.Rectangle;
import flash.display.Sprite;
import flash.display.BitmapData;
    internal class Square {
        private var myColor:uint;
        private var x:Number;
        private var y:Number;
        private var rect:Rectangle;
        public function Square(X:Number,Y:Number, W:Number = 50, H:Number = 50 ):void {
            x = X;
            y = Y;
            rect = new Rectangle(x,y,W,H);
            colorize();
        }
        public function colorize():void {
            myColor = myColor+(Math.random()*0xFFFFFF)/1000;
        }
        public function setColor(c:uint):void {
            myColor = c;
        }

        public function setScale(scale:int):void {
            rect.width=rect.width*scale;
            rect.height=rect.height*scale;
        }

        public function render(target:BitmapData):void {
            target.fillRect(rect,myColor);
        }
    }