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

can you pass the Acid test? (090612)

090612 - 同じものの始点終点違いを四つ重ねる。
コードがクソ汚いが、取りあえず恥ずかしくないし気にしない。
090611 - BitmapDataで軌跡というか残像ををつけてみた
Get Adobe Flash player
by OneInchPunch 13 Jun 2009
    Embed
// forked from OneInchPunch's forked from: bubble with bezier curve of Tweener (090226)
// 090612 - 同じものの始点終点違いを四つ重ねる。
// コードがクソ汚いが、取りあえず恥ずかしくないし気にしない。
// forked from OneInchPunch's bubble with bezier curve of Tweener (090226)
// 090611 - BitmapDataで軌跡というか残像ををつけてみた

package {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.filters.*;
    import flash.utils.*;
    import caurina.transitions.Tweener;
    import caurina.transitions.properties.CurveModifiers;
    
    [SWF(backgroundColor="#000000", frameRate=30)]
    
    public class bezier extends MovieClip {
        private var stageW:Number = stage.stageWidth;
        private var stageH:Number = stage.stageHeight;
        
        // コンテナMC
        private var containerMC:MovieClip = new MovieClip();
        
        // 共通設定
        private var tweenTime:Number = 30;
        
        // ================================================== コンストラクタ
        public function bezier() {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            CurveModifiers.init();
            
            var dotTimer:Timer = new Timer(200);
            dotTimer.addEventListener("timer", drawDot);
            dotTimer.addEventListener("timer", drawDot2);
            dotTimer.addEventListener("timer", drawDot3);
            dotTimer.addEventListener("timer", drawDot4);
            dotTimer.start();
            
            xBmp();
            
            addChild(containerMC);
            
            // take a capture after 30 sec
            Wonderfl.capture_delay( 30 );
        }
        
        
        // ================================================== 左から右へ
        public function drawDot(event:TimerEvent):void {
            // 乱数
            var dotSize:Number = Math.random()*5;
            var dotColor:Number = Math.random()*(0xffffff);
            
            // ドット作成
            var dot:Sprite = new Sprite();
            dot.graphics.beginFill(dotColor);
            dot.graphics.drawCircle(0, 0, dotSize);
            dot.graphics.endFill();
            
            // ドットのMC
            var dot_mc:MovieClip = new MovieClip();
            dot_mc.x = 15;
            dot_mc.y = 225;
            dot_mc.alpha = 0.1;
            dot_mc.addChild(dot);
            
            containerMC.addChild(dot_mc);
            
            // 動かす
            xMove(dot_mc, dotColor);
        }
        
        public function xMove(dot_mc:MovieClip, dotColor:Number):void {
            // 乱数
            var bezierY:Number = Math.random()*stageH;
            
            // Tweenerパラメータ
            Tweener.addTween(dot_mc, {
                x:stageW-15, y:stageH/2,
                scaleX:dot_mc.width*1.5, scaleY:dot_mc.height*1.5,
                alpha:0.4,
                _bezier:[{x:15, y:stageH/2}, {x:stageW/2, y:bezierY}, {x:stageW-15, y:stageH/2}],
                time:tweenTime,
                transition:"linear",
                onComplete:xEnd, onCompleteParams:[dot_mc]
            });
            Tweener.addTween(dot_mc, {
                scaleX:dot_mc.width*1.5, scaleY:dot_mc.height*1.5,
                time:tweenTime/2,
                transition:"linear"
            });
            Tweener.addTween(dot_mc, {
                scaleX:dot_mc.width*0.5, scaleY:dot_mc.height*0.5,
                time:tweenTime/2,
                delay:tweenTime/2,
                transition:"linear"
            });
            
            // コールバック関数
            function xEnd(targetDot:MovieClip):void {
                containerMC.removeChild(targetDot);
            }
        }
        
        
        // ================================================== 上から下へ
        public function drawDot2(event:TimerEvent):void {
            // 乱数
            var dotSize2:Number = Math.random()*5;
            var dotColor2:Number = Math.random()*(0xffffff);
            
            // ドット作成
            var dot2:Sprite = new Sprite();
            dot2.graphics.beginFill(dotColor2);
            dot2.graphics.drawCircle(0, 0, dotSize2);
            dot2.graphics.endFill();
            
            // ドットのMC
            var dot_mc2:MovieClip = new MovieClip();
            dot_mc2.x = stageW / 2;
            dot_mc2.y = 15;
            dot_mc2.alpha = 0.1;
            dot_mc2.addChild(dot2);
            
            containerMC.addChild(dot_mc2);
            
            // 動かす
            xMove2(dot_mc2, dotColor2);
        }
        
        public function xMove2(dot_mc2:MovieClip, dotColor2:Number):void {
            // 乱数
            var bezierX:Number = Math.random()*stageW;
            
            // Tweenerパラメータ
            Tweener.addTween(dot_mc2, {
                x:stageW/2, y:stageH-15,
                alpha:0.4,
                _bezier:[{x:stageW/2, y:15}, {x:bezierX, y:stageH/2}, {x:stageW/2, y:stageH-15}],
                time:tweenTime,
                transition:"linear",
                onComplete:xEnd2, onCompleteParams:[dot_mc2]
            });
            Tweener.addTween(dot_mc2, {
                scaleX:dot_mc2.width*1.5, scaleY:dot_mc2.height*1.5,
                time:tweenTime/2,
                transition:"linear"
            });
            Tweener.addTween(dot_mc2, {
                scaleX:dot_mc2.width*0.5, scaleY:dot_mc2.height*0.5,
                time:tweenTime/2,
                delay:tweenTime/2,
                transition:"linear"
            });
            
            // コールバック関数
            function xEnd2(targetDot2:MovieClip):void {
                containerMC.removeChild(targetDot2);
                }
            }
            
            
            // ================================================== 右から左へ
            public function drawDot3(event:TimerEvent):void {
                // 乱数
                var dotSize3:Number = Math.random()*5;
                var dotColor3:Number = Math.random()*(0xffffff);
                
                // ドット作成
                var dot3:Sprite = new Sprite();
                dot3.graphics.beginFill(dotColor3);
                dot3.graphics.drawCircle(0, 0, dotSize3);
                dot3.graphics.endFill();
                
                // ドットのMC
                var dot_mc3:MovieClip = new MovieClip();
                dot_mc3.x = stageW-15;
                dot_mc3.y = stageH/2;
                dot_mc3.alpha = 0.1;
                dot_mc3.addChild(dot3);
                
                containerMC.addChild(dot_mc3);
                
                // 動かす
                xMove3(dot_mc3, dotColor3);
            }
            
            public function xMove3(dot_mc3:MovieClip, dotColor3:Number):void {
                // 乱数
                var bezierY:Number = Math.random()*stageH;
                
                // Tweenerパラメータ
                Tweener.addTween(dot_mc3, {
                    x:15, y:stageH/2,
                    scaleX:dot_mc3.width*1.5, scaleY:dot_mc3.height*1.5,
                    alpha:0.4,
                    _bezier:[{x:stageW-15, y:stageH/2}, {x:stageW/2, y:bezierY}, {x:15, y:stageH/2}],
                    time:tweenTime,
                    transition:"linear",
                    onComplete:xEnd3, onCompleteParams:[dot_mc3]
                });
                Tweener.addTween(dot_mc3, {
                    scaleX:dot_mc3.width*1.5, scaleY:dot_mc3.height*1.5,
                    time:tweenTime/2,
                    transition:"linear"
                });
                Tweener.addTween(dot_mc3, {
                    scaleX:dot_mc3.width*0.5, scaleY:dot_mc3.height*0.5,
                    time:tweenTime/2,
                    delay:tweenTime/2,
                    transition:"linear"
                });
                
                // コールバック関数
                function xEnd3(targetDot3:MovieClip):void {
                    containerMC.removeChild(targetDot3);
                }
            }
            
            
            // ================================================== 下から上へ
            public function drawDot4(event:TimerEvent):void {
                // 乱数
                var dotSize4:Number = Math.random()*5;
                var dotColor4:Number = Math.random()*(0xffffff);
                
                // ドット作成
                var dot4:Sprite = new Sprite();
                dot4.graphics.beginFill(dotColor4);
                dot4.graphics.drawCircle(0, 0, dotSize4);
                dot4.graphics.endFill();
                
                // ドットのMC
                var dot_mc4:MovieClip = new MovieClip();
                dot_mc4.x = stageW/2;
                dot_mc4.y = stageH-15;
                dot_mc4.alpha = 0.1;
                dot_mc4.addChild(dot4);
                
                containerMC.addChild(dot_mc4);
                
                // 動かす
                xMove4(dot_mc4, dotColor4);
            }
            
            public function xMove4(dot_mc4:MovieClip, dotColor4:Number):void {
                // 乱数
                var bezierX:Number = Math.random()*stageW;
                
                // Tweenerパラメータ
                Tweener.addTween(dot_mc4, {
                    x:stageW/2, y:15,
                    alpha:0.4,
                    _bezier:[{x:stageW/2, y:stageH-15}, {x:bezierX, y:stageH/2}, {x:stageW/2, y:15}],
                    time:tweenTime,
                    transition:"linear",
                    onComplete:xEnd4, onCompleteParams:[dot_mc4]
                });
                Tweener.addTween(dot_mc4, {
                    scaleX:dot_mc4.width*1.5, scaleY:dot_mc4.height*1.5,
                    time:tweenTime/2,
                    transition:"linear"
                });
                Tweener.addTween(dot_mc4, {
                    scaleX:dot_mc4.width*0.5, scaleY:dot_mc4.height*0.5,
                    time:tweenTime/2,
                    delay:tweenTime/2,
                    transition:"linear"
                });
                
                // コールバック関数
                function xEnd4(targetDot2:MovieClip):void {
                    containerMC.removeChild(targetDot2);
                    }
                }
                
                
                // ================================================== ビットマップキャプチャ
                private function xBmp():void {
                    var bmpTimer:Timer = new Timer(100);
                    bmpTimer.addEventListener("timer", drawing);
                    bmpTimer.start();
                    
                    // ビットマップデータ
                    var bmpd:BitmapData = new BitmapData(stageW, stageH, true, 0x00000000);
                    var colors:ColorTransform=new ColorTransform(1, 1, 1, 0.9);
                    
                    // フィルタ
                    var zero:Point = new Point(0, 0);
                    var blur:BlurFilter = new BlurFilter();
                    
                    function drawing(event:TimerEvent):void {
                        bmpd.lock();
                        bmpd.colorTransform(bmpd.rect, colors);
                        bmpd.applyFilter(bmpd, bmpd.rect, zero, blur);
                        bmpd.draw(containerMC);
                        bmpd.unlock();
                    }
                    
                    //表示用Bitmap
                    var bmp:Bitmap = new Bitmap(bmpd, "auto", true);
                    addChild(bmp);
                }
            }
        }