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

Read And Travel

When one pixel is fully grown, it bears and lets its neighbors (of up, down, left, right 4 sides) grow. But some of the pixels should have been colored are not. BUG!!!

「成長」した小さい四角、周りの四つの四角を「生み」ます。しかし、色がついているべきの「成長」した四角に色がついてない場合がありますね。バグ!
Get Adobe Flash player
by GreekFellows 14 Jul 2012
/**
 * Copyright GreekFellows ( http://wonderfl.net/user/GreekFellows )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/paLJ
 */

package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFormat;
    
    /**
     * ...
     * @author Greek Fellows
     */
    public class RAT extends Sprite 
    {
        private var array:Array;
        
        private var bd:BitmapData;
        private var b:Bitmap;
        private var s:Sprite;
        
        private const unit:int = 2;
        
        public function RAT():void 
        {
            text("cheesebrain\ngreekfellows");
            
            var bitmapData:BitmapData = new BitmapData(465, 465);
            bitmapData.draw(this);
            
            this.removeChildren();
            
            this.array = [];
            
            for (var ver:int = 0; ver < 465; ver += unit) {
                for (var hor:int = 0; hor < 465; hor += unit) {
                    if (bitmapData.getPixel(hor, ver) != 0xffffff) {
                        this.array.push( { gx:hor, gy:ver, size:0, x:0, y:0, ax:0, ay:0, asi:unit / 210, divide:20, appeared:false, stopped:false } );
                    }
                }
            }
            
            bd = new BitmapData(465, 465);
            b = new Bitmap(bd);
            this.addChild(b);
            s = new Sprite();
            
            this.addEventListener(Event.ENTER_FRAME, travel);
        }
        
        private function travel(e:Event):void {
            s.graphics.clear();
            
            s.graphics.beginFill(0xffffff, 1);
            s.graphics.drawRect(0, 0, 465, 465);
            s.graphics.endFill();
            
            for (var i:int = 0; i < this.array.length; i++) {
                if (!this.array[i].appeared) {
                    if (Math.floor(Math.random() * 5000) == 0) {
                        this.array[i].appeared = true;
                        this.array[i].x = this.array[i].gx;
                        this.array[i].y = this.array[i].gy;
                    }
                } else {
                    s.graphics.beginFill(0x000000, 1);
                    s.graphics.drawRect(this.array[i].x - this.array[i].size / 2, this.array[i].y - this.array[i].size / 2, this.array[i].size, this.array[i].size);
                    s.graphics.endFill();
                    
                    this.array[i].x += this.array[i].ax * this.array[i].divide;
                    this.array[i].y += this.array[i].ay * this.array[i].divide;
                    this.array[i].size += this.array[i].asi * this.array[i].divide;
                    
                    if (!this.array[i].stopped) {
                        if (this.array[i].divide <= 0) {
                            this.array[i].divide = 0;
                            this.array[i].x = this.array[i].gx;
                            this.array[i].y = this.array[i].gy;
                            this.array[i].size = unit;
                            this.array[i].stopped = true;
                            
                            // left
                            var indL:int = find(this.array[i].gx - unit, this.array[i].gy);
                            if (indL != -1) {
                                this.array[indL].appeared = true;
                                this.array[indL].x = this.array[i].gx;
                                this.array[indL].y = this.array[i].gy;
                                this.array[indL].ax = (this.array[indL].gx - this.array[indL].x) / 210;
                                this.array[indL].ay = (this.array[indL].gy - this.array[indL].y) / 210;
                            }
                            // right
                            var indR:int = find(this.array[i].gx + unit, this.array[i].gy);
                            if (indR != -1) {
                                this.array[indR].appeared = true;
                                this.array[indR].x = this.array[i].gx;
                                this.array[indR].y = this.array[i].gy;
                                this.array[indR].ax = (this.array[indR].gx - this.array[indR].x) / 210;
                                this.array[indR].ay = (this.array[indR].gy - this.array[indR].y) / 210;
                            }
                            // up
                            var indU:int = find(this.array[i].gx, this.array[i].gy - unit);
                            if (indU != -1) {
                                this.array[indU].appeared = true;
                                this.array[indU].x = this.array[i].gx;
                                this.array[indU].y = this.array[i].gy;
                                this.array[indU].ax = (this.array[indU].gx - this.array[indU].x) / 210;
                                this.array[indU].ay = (this.array[indU].gy - this.array[indU].y) / 210;
                            }
                            // down
                            var indD:int = find(this.array[i].gx, this.array[i].gy + unit);
                            if (indD != -1) {
                                this.array[indD].appeared = true;
                                this.array[indD].x = this.array[i].gx;
                                this.array[indD].y = this.array[i].gy;
                                this.array[indD].ax = (this.array[indD].gx - this.array[indD].x) / 210;
                                this.array[indD].ay = (this.array[indD].gy - this.array[indD].y) / 210;
                            }
                        } else {
                            this.array[i].divide--;
                        }
                    }
                }
            }
            
            bd.draw(s);
        }
        
        private function find(x:Number, y:Number):int {
            var i:int = -1;
            
            for (var ind:int = 0; ind < this.array.length; ind++) {
                if (this.array[ind].gx == x && this.array[ind].gy == y) {
                    i = ind;
                }
            }
            
            return i;
        }
        
        private function text(str:String):TextField {
            var tf:TextField = new TextField();
            tf.text = str;
            
            var fm:TextFormat = new TextFormat();
            fm.font = "Segoe UI Light";
            fm.size = 84;
            fm.align = "center";
            
            tf.setTextFormat(fm);
            
            tf.width = tf.textWidth;
            tf.height = tf.textHeight + 5;
            tf.x = 465 / 2 - tf.textWidth / 2;
            tf.y = 465 / 2 - tf.textHeight / 2;
            
            this.addChild(tf);
            
            return tf;
        }
        
    }
    
}