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

四畳半神話悶絶体系

未完 ふぁぼっちゃ嫌よ
たまにエラる
*そんなに見つめちゃいや
*エラー回避と、線幅線色単色、背景色変更
Get Adobe Flash player
by Nyarineko 04 Feb 2016
/**
 * Copyright Nyarineko ( http://wonderfl.net/user/Nyarineko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/i99S
 */

/*
  未完 ふぁぼっちゃ嫌よ
  たまにエラる
  *そんなに見つめちゃいや
  *エラー回避と、線幅線色単色、背景色変更
*/
package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.Point;

    [SWF(width = "465", height = "465", backgroundColor = "0x99cc33")]
    public class Main extends Sprite
    {
        private const _BOX:uint = 20;
        private var _mySprite:Sprite;
        
        private var _w:Number = 0;
        
        private var _centerBox:Box = new Box();

        public function Main():void
        {
            var twList:Array = [];
            var boxList:Array = [];
            
            var parentBox:Box = _centerBox;
            var listBox:Box = _centerBox;
            parentBox.h = 50;
            parentBox.w = 50;
            parentBox.x = 210;
            parentBox.y = 210;
            
            var newBox:Box = new Box();
            for(var i:uint = 0;i < _BOX;i++){
                newBox = new Box();
                if(parentBox.top < parentBox.w){
                    //親の上に配置する箱を作成
                    newBox.y = parentBox.y - newBox.h;
                    newBox.x = parentBox.x + parentBox.top;
                    
                    parentBox.topArray.push(newBox);
                    //2個目以降
                    if(parentBox.top > 0){
                        parentBox.topArray[parentBox.topArray.length - 1].rightArray.push(newBox);
                        parentBox.topArray[parentBox.topArray.length - 1].rightArray.right += newBox.h;
                    }
                    parentBox.top += newBox.w;
                    
                    newBox.bottomArray.push(parentBox);
                    newBox.bottom += parentBox.w;
                    
                }else if(parentBox.right < parentBox.h){
                    //親の右に配置する箱を作成
                    newBox.x = parentBox.x + parentBox.w;
                    newBox.y = parentBox.y + parentBox.right;
                    
                    //下に箱があるかどうか
                    if(parentBox.bottomArray.length > 0) newBox.h = parentBox.h - parentBox.right;
                    
                    parentBox.rightArray.push(newBox);
                    //2個目以降
                    if(parentBox.right > 0){
                        parentBox.rightArray[parentBox.rightArray.length - 1].bottomArray.push(newBox);
                        parentBox.rightArray[parentBox.rightArray.length - 1].bottomArray.bottom += newBox.w;
                    }
                    parentBox.right += newBox.h;
                    
                    newBox.leftArray.push(parentBox);
                    newBox.left += parentBox.h;
                    
                    trace(i+"@"+parentBox.topArray.length);
                    trace(parentBox.top);
                    if(parentBox.top > parentBox.w && parentBox.topArray.length > 0){
                        parentBox.topArray[parentBox.topArray.length - 1].bottomArray.push(newBox);
                        newBox.top = parentBox.top - parentBox.w;
                    }
                    
                }else if(parentBox.bottom < parentBox.w){
                    //親の下に配置する箱を作成
                    newBox.y = parentBox.y + parentBox.h;
                    newBox.x = parentBox.x + parentBox.w - newBox.w - parentBox.bottom;
                    
                    
                    parentBox.bottomArray.push(newBox);
                    //2個目以降
                    if(parentBox.bottom > 0){
                        parentBox.bottomArray[parentBox.bottomArray.length - 1].leftArray.push(newBox);
                        parentBox.bottomArray[parentBox.bottomArray.length - 1].leftArray.left += newBox.w;
                    }
                    parentBox.bottom += newBox.w;
                    
                    newBox.topArray.push(parentBox);
                    newBox.top += parentBox.w;
                    
                }else if(parentBox.left < parentBox.h){
                    //親の左に配置する箱を作成
                    newBox.x = parentBox.x - newBox.w;
                    newBox.y = parentBox.y + parentBox.h - newBox.h - parentBox.left;
                    
                    parentBox.leftArray.push(newBox);
                    //2個目以降
                    if(parentBox.left > 0){
                        parentBox.leftArray[parentBox.leftArray.length - 1].topArray.push(newBox);
                        parentBox.leftArray[parentBox.leftArray.length - 1].topArray.top += newBox.w;
                    }
                    parentBox.left += newBox.h;
                    
                    newBox.rightArray.push(parentBox);
                    newBox.right += parentBox.h;
                    
                }else{
                    parentBox = parentBox.linkBox;
                    i--;
                    continue;
                }
                //リンク作成
                listBox.linkBox = newBox;
                newBox.parentBox = parentBox;
                listBox = newBox;
            }
            _mySprite = new Sprite();
            addChild(_mySprite);
            stage.addEventListener(Event.ENTER_FRAME,myEnterFrame);
        }
        
        private function myEnterFrame(e:Event):void
        {
            var bufBox:Box = _centerBox;
            _mySprite.graphics.clear();
            while(bufBox.linkBox){
                _mySprite.graphics.lineStyle(8,bufBox.lcol,1, true, "none","none","miter");
                _mySprite.graphics.beginFill(bufBox.fcol,1);
                _mySprite.graphics.drawRect(bufBox.x,bufBox.y,bufBox.w ,bufBox.h);
                bufBox = bufBox.linkBox;
            }
            _mySprite.graphics.endFill();
        }
    }
}


class Box
{
    public var topArray:Array = []; //上の箱
    public var leftArray:Array = []; //左の箱
    public var rightArray:Array = []; //右の箱
    public var bottomArray:Array = []; //下の箱
    
    public var parentBox:Box; //親の箱
    public var linkBox:Box; //次の箱
    
    private var _lcol:uint;
    private var _fcol:uint;
    
    private var _w:Number;
    private var _h:Number;
    
    private var _x:Number;
    private var _y:Number;
    
    public var top:Number = 0;
    public var right:Number = 0;
    public var bottom:Number = 0;
    public var left:Number = 0;
    
    public function Box():void
    {
        //_lcol = 0xFFFFFF*Math.random();
        _lcol = 0x331100;
        _fcol = 0xFFFFFF*Math.random();
        _x = 210*Math.random() + 100;
        _y = 210*Math.random() + 100;
        
        _w = 80*Math.random() + 20;
        _h = 80*Math.random() + 20;
    }
    
    public function set x(val:Number):void{_x = val}
    public function get x():Number{return _x}
    
    public function set y(val:Number):void{_y = val}
    public function get y():Number{return _y}
    
    public function set w(val:Number):void{_w = val}
    public function get w():Number{return _w}
    
    public function set h(val:Number):void{_h = val}
    public function get h():Number{return _h}
    
    public function set lcol(val:uint):void{_lcol = val}
    public function get lcol():uint{return _lcol}
    
    public function set fcol(val:uint):void{_fcol = val}
    public function get fcol():uint{return _fcol}
}