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: hyperdiscosquares

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

// 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 _buffer: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);
            _squares = new Vector.<Square>(100);
            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);
                }
            }         
        }
        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);
                }
                _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);
        }

    }
}
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):void {
            x = X;
            y = Y;
            rect = new Rectangle(x,y,50,50);
            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);
        }
    }