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: mikumiku polka dotted

code in progress.
Get Adobe Flash player
by kt3k 17 Nov 2010
// forked from kt3k's mikumiku polka dotted
// forked from kt3k's forked from: Blur Circle
// forked from ll_koba_ll's Blur Circle

package
{
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.net.URLStream;
    import flash.media.Sound;
    import flash.media.Video;
    import flash.net.NetStream;
    import flash.net.NetConnection;    
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.filters.*;

    [SWF(frameRate="60", backgroundColor="#000000")]

    public class Rotationlight extends Sprite
    {
        private var time:Number;
        private var song_ph0:Number = 800;
        private var song_ph1:Number = 1800;
        private var song_mid:Number = 3000;
        private var song_end:Number = 5000;
        private var song_ph2:Number = 6000;
        
        private var blur:BlurFilter;
        private var bigBlurHor:BlurFilter;
        private var bigBlurVer:BlurFilter;
        private var container:Sprite;
        private var source:Sprite;
        private var bmpd:BitmapData;
        
        private var thanks:TextField = new TextField();
        private var tf:TextFormat = new TextFormat();
                
        private var snd:Sound;
        private var soundChannel:SoundChannel = new SoundChannel;

        public function Rotationlight()
        {
            stage.scaleMode = StageScaleMode.SHOW_ALL;
            stage.align = StageAlign.TOP;
            stage.quality = StageQuality.LOW;        
            init();
            initSound();
            addEventListener(Event.ENTER_FRAME, update);
        }

        private function init():void
        {
            time = 1;
            blur = new BlurFilter(1.1,1.1);
            bigBlurHor = new BlurFilter(10, 10);
            bigBlurVer = new BlurFilter(1, 80);
            bmpd = new BitmapData(500, 500, true, 0x00FFFFFF);
            container = new Sprite();
            source = new Sprite();
            source.scaleX = 0;
            source.scaleY = 0;
            addChild(new Bitmap(bmpd));
            container.addChild(source);
            with(source.graphics)
            {
                beginFill(0x00bbff);
                drawRect(-20,-20,40,40);
                endFill();
            }
        }
        
        private function initSound():void
        {
            snd = new Sound;
            snd.load(new URLRequest("http://penv.org/mikumiku.mp3"));
            soundChannel = snd.play(0,1);
        }


        private function update(e:Event = null):void
        {
            bmpd.draw(container, null, null, BlendMode.DARKEN);
            bmpd.applyFilter(bmpd, bmpd.rect, new Point(), blur);
            if (Math.random() < 0.05){
                if (Math.random() < 0.8) bmpd.applyFilter(bmpd, bmpd.rect, new Point(), bigBlurHor);
                else bmpd.applyFilter(bmpd, bmpd.rect, new Point(), bigBlurVer);
            }
            
            
            if (song_mid < time && time < song_mid + 0x100)
            {
                if (this.opaqueBackground < 0xffffff)
                {
                    this.opaqueBackground += 0x010101;
                }
            }
            
            if (song_end < time)
            {
                if (this.opaqueBackground > 0x00ffff)
                {
                    this.opaqueBackground += 0xff0000;
                }
                else if (this.opaqueBackground != 0x00bbff)
                {
                    this.opaqueBackground += 0x00ff00;
                }
            }

            time += 1;

            var x:Number = 500;
            var y:Number = 500;
            x = Math.round(x/50);
            y = Math.round(y/50);

            var scale:Number = 0.6 + Math.random() * 0.3;
            source.scaleX = scale;
            source.scaleY = scale;
       
            var ofs:Number = 0;
            if (time < song_ph0)
            {
                x = x/2;
                y = y/2;
                ofs = x/4 * 50 + 35;

                if(Math.random() > 0.1)
                {
                    source.scaleX = 0;
                    source.scaleY = 0 ;
                }
             }
            
            if (song_ph0 < time && time < song_ph1)
            {
                if(Math.random() > 0.4)
                {
                    source.scaleX = 0;
                    source.scaleY = 0 ;
                }
            }
            if (song_ph2 < time)
            {
                source.scaleX = 0;
                source.scaleY = 0;
            }
            if (song_ph2 + 100 == time)
            {
                tf.size = 20;
                thanks.text = "thanks for watching.";
                thanks.setTextFormat(tf);
                thanks.autoSize = "left";
                thanks.x = 200;
                thanks.y = 300;
                this.addChild(thanks);
            }

            
            source.x = ofs + dice(x) * 50 + 15;
            source.y = ofs + dice(y) * 50 + 15;
        }
        
    }
}

// utils
function uniform(x:Number, y:Number):Number
{
    if(x - y > 0)
    {
        var w:Number = y;
        y = x;
        x = w;
    }
    return x + Math.random()*(y-x)
}

function dice(n:Number = 6):Number
{
    return Math.round(Math.random() * n);
}