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

四畳半神話大系的な何か

/**
 * Copyright Nyarineko ( http://wonderfl.net/user/Nyarineko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8muP
 */

package
{
    import flash.display.*;
    import flash.events.*;
    
    import org.libspark.betweenas3.BetweenAS3;
    import org.libspark.betweenas3.easing.*;
    import org.libspark.betweenas3.tweens.ITween;
    import org.libspark.betweenas3.events.TweenEvent;

    [SWF(width = "465", height = "465", backgroundColor = "0xffff99")]
    public class Main extends Sprite
    {
        private const EZ:Number = .6; //速度が変わるよ!
        private var _tw:ITween;
        private var _container:Sprite = new Sprite();
        
        
        private var MAX:int = 20;
        private var _cnt:int = 0;
        private var _topBox:Box;
        private var _lastBox:Box;
        
        public function Main():void
        {
            var w:Number = Math.random()*200 + 50;
            var h:Number = Math.random()*200 + 50;
            var box:Box = new Box(w,h);
            _topBox = box;
            _lastBox = box;
            
            _container.rotationZ = Math.random() * 180 - 90;
            _container.x = 165;
            _container.y = 165;
                
            //_boxs = box;
            
            addChild(_container);
            _container.addChild(box);
            
            _tw = BetweenAS3.parallel(
                BetweenAS3.tween(box,{width:box.width},{width:0},EZ,Quint.easeInOut),
                BetweenAS3.tween(box,{height:box.height},{height:0},EZ,Quint.easeInOut));
            _tw.addEventListener(TweenEvent.COMPLETE,compTween);
            _tw.play();
        }
        
        private function compTween(e:TweenEvent):void
        {
            _tw.removeEventListener(TweenEvent.COMPLETE,compTween);
            _cnt++;
            
            var twArray:Array = [];
            var w:Number = Math.random()*200 + 50;
            var h:Number = Math.random()*200 + 50;
            
            var box:Box = _topBox;
            //途中の部屋
            while(box.linkBox){
                if(_lastBox.width>_lastBox.height){
                    twArray.push(BetweenAS3.parallel(
                        BetweenAS3.tween(box,{x:box.x - _lastBox.width/2},null,EZ,Quint.easeInOut),
                        BetweenAS3.tween(box,{y:box.y - _lastBox.height+2},null,EZ,Quint.easeInOut)
                    ));
                }else{
                    twArray.push(BetweenAS3.parallel(
                        BetweenAS3.tween(box,{x:box.x - _lastBox.width+2},null,EZ,Quint.easeInOut),
                        BetweenAS3.tween(box,{y:box.y - _lastBox.height/2},null,EZ,Quint.easeInOut)
                    ));
                }
                box = box.linkBox;
            }
            
            //最後の部屋と新しい部屋
            var box_new:Box = new Box(w,h);
            _container.addChild(box_new);
            
            if(box.width>box.height){
                twArray.push(BetweenAS3.parallel(
                    BetweenAS3.tween(box,{x:box.x - box.width/2},null,EZ,Quint.easeInOut),
                    BetweenAS3.tween(box,{y:box.y - box.height+2},null,EZ,Quint.easeInOut),
                    BetweenAS3.tween(box_new,{x:0},{x:box.width/2},EZ,Quint.easeInOut),
                    BetweenAS3.tween(box_new,{y:0},{y:box.height},EZ,Quint.easeInOut)
                ));
            }else{
                twArray.push(BetweenAS3.parallel(
                    BetweenAS3.tween(box,{x:box.x - box.width+2},null,EZ,Quint.easeInOut),
                    BetweenAS3.tween(box,{y:box.y - box.height/2},null,EZ,Quint.easeInOut),
                    BetweenAS3.tween(box_new,{x:0},{x:box.width},EZ,Quint.easeInOut),
                    BetweenAS3.tween(box_new,{y:0},{y:box.height/2},EZ,Quint.easeInOut)
                ));
            }
            twArray.push(BetweenAS3.parallel(
                BetweenAS3.tween(box_new,{width:w},{width:0},EZ,Quint.easeInOut),
                BetweenAS3.tween(box_new,{height:h},{height:0},EZ,Quint.easeInOut)));
            
            //新しい配列をリストに追加
            box.linkBox = box_new;
            _lastBox = box_new;
            //10個以上になったら古いの消すよ
            if(_cnt > 10){
                var bufBox:Box = _topBox.linkBox;
                _container.removeChild(_topBox);
                _topBox = bufBox;
            }
            //ちょいちょい角度を変えてみる
            if(_cnt % 3 == 0){
                twArray.push(BetweenAS3.tween(_container,{rotationZ:Math.random() * 180 - 90},null,EZ,Quint.easeInOut),
                BetweenAS3.tween(_container,{z:Math.random() * 1000},null,EZ,Quint.easeInOut));
            }
            _tw = BetweenAS3.parallelTweens( twArray );
            _tw.addEventListener(TweenEvent.COMPLETE,compTween);
            
            _tw.play();
        }
    }
}

import flash.display.Sprite;

class Box extends Sprite
{
    public var linkBox:Box = null;
    public function Box(w:Number,h:Number):void
    {
        var lineColor:uint = 0x000000;
        var fillColor:uint = 0xFFFFFF*Math.random();
        graphics.lineStyle(2,lineColor,1,false,"none","square");
        graphics.beginFill(fillColor);
        graphics.drawRoundRect(0,0,w,h,4,4);
        graphics.endFill();
    }
}