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

No,Thank you!

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

// forked from Event's Simple MediaRSS Viewer
package {
    import flash.filters.BlurFilter;
    import flash.system.LoaderContext;   
    import flash.display.*;
    import flash.events.*;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.*;
    import flash.system.Security;
    import flash.utils.Timer;
    
    import org.si.sion.SiONData;
    import org.si.sion.SiONDriver;
    import org.si.sion.SiONVoice;
    import org.si.sion.utils.SiONPresetVoice;    
    
    
    public class MediaRSSReader extends Sprite {
        private var _feed:String = "http://api.flickr.com/services/feeds/photos_public.gne?tags=kon,ed&format=rss_200";
        private var media:Namespace = new Namespace("http://search.yahoo.com/mrss/");
        
        public function MediaRSSReader() {
            Wonderfl.capture_delay(30);
            
            var ldr:URLLoader = new URLLoader;
            ldr.addEventListener(Event.COMPLETE, function _load(e:Event):void {
                ldr.removeEventListener(Event.COMPLETE, _load);
                onImageLoaded(XML(ldr.data)..media::thumbnail.@url.toXMLString().split('\n'));
            });
            ldr.load(new URLRequest(_feed));
        }
        
        private var _images:Array;
        
        private function onImageLoaded($images:Array):void {
            _images = $images;
            init();
        }
        
        //forked from http://wonderfl.net/c/gcsz
        private var driver:SiONDriver;
        private var mml:String;
        private var channel:SoundChannel;
        private var PATH:String = "http://www.dreamana.com/lab/sion/";
        
        private function init():void
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            Security.loadPolicyFile("http://www.dreamana.com/crossdomain.xml");
            
            //Driver
            driver = new SiONDriver();
                        
            //SamplerSounds
            loadSounds(PATH + "JV1080.swf");
        }
        
        private function loadSounds(url:String):void
        {
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, soundLoaded);
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, soundLoading);
            loader.load(new URLRequest(url));
        }
        
        private function soundLoading(e:ProgressEvent):void
        {
            var w:int = 300;
            var h:int = 4;
            var ox:int = (stage.stageWidth - w)/2;
            var oy:int = (stage.stageHeight - h)/2;
            var g:Graphics = this.graphics;
            g.clear();
            g.beginFill(0xffffff);
            g.drawRect(ox, oy, w, h);
            g.endFill();
            g.beginFill(0xff0000);
            g.drawRect(ox, oy, w * (e.bytesLoaded / e.bytesTotal), h);
            g.endFill();
        }
        
        private function soundLoaded(e:Event):void
        {
            this.graphics.clear();
            
            var loaderInfo:LoaderInfo = e.currentTarget as LoaderInfo;
            loaderInfo.removeEventListener(Event.COMPLETE, soundLoaded);
            var lib:Object = loaderInfo.content;
            for(var i:int=27; i < 88; ++i) {
                var snd:Sound = lib.getInstance(GMStandard.percussion[i]) as Sound;
                if(snd != null) driver.setSamplerSound(i, snd);
            }
            
            loadMML(PATH + "nothankyou.txt");
        }
        
        private function loadMML(url:String):void
        {
            var loader:URLLoader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, mmlLoaded);
            loader.load(new URLRequest(url));
        }
        
        private function mmlLoaded(e:Event):void
        {
            var data:String = URLLoader(e.currentTarget).data;
            this.mml = data.replace(/\r\n/g, '\n');
                        
            run();
        }
        
        private var container:Sprite;
        private var timer:Timer;
        private var count:int = 1;
        private var lastPhoto:Bitmap;
               
        private function run():void
        {
            container = new Sprite();
            this.addChild(container);
            
            timer = new Timer(10000);
            timer.addEventListener(TimerEvent.TIMER, onTick);
            timer.start();
            showPhoto(0);
            
            var data:SiONData = driver.compile(this.mml);
            
            var presetVoice:SiONPresetVoice = new SiONPresetVoice();
            var voice0:SiONVoice = presetVoice["valsound.lead7"];
            var voice1:SiONVoice = presetVoice["valsound.guitar2"];
            var voice2:SiONVoice = presetVoice["valsound.bass14"];
            var voice3:SiONVoice = presetVoice["valsound.bell12"];
            data.setVoice(0, voice0);
            data.setVoice(1, voice1);
            data.setVoice(2, voice2);
            data.setVoice(3, voice3);
                        
            //Let's rock!
            channel = driver.play(data);
            
            this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private var blur:BlurFilter = new BlurFilter();
        private var a:Array = [blur];
        private function onEnterFrame(e:Event):void
        {
            container.z = -channel.leftPeak * 100;
            blur.blurX = blur.blurY = channel.rightPeak * 16;
            container.filters = a;         
        }
        
        private function onTick(e:Event):void
        {
            if(count > _images.length-1) {
                lastPhoto.addEventListener(Event.ENTER_FRAME, bmpFadeOut);
                timer.stop();
            }
            else {
                showPhoto(count);
                count++;
            }
        }
        
        private function showPhoto(i:int):void
        {
            var url:String = _images[ i ].replace ( "_s" , "" );
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, photoLoaded);
            loader.load(new URLRequest(url), new LoaderContext(true));
        }
        
        private function photoLoaded(e:Event):void
        {
            var loaderInfo:LoaderInfo = e.currentTarget as LoaderInfo;
            var bmp:Bitmap = loaderInfo.content as Bitmap;
            bmp.alpha = 0;
            bmp.x = int((stage.stageWidth-bmp.width)/2);
            bmp.y = int((stage.stageHeight-bmp.height)/2);
            container.addChild(bmp);
            bmp.addEventListener(Event.ENTER_FRAME, bmpFadeIn);
        }
        
        private function bmpFadeIn(e:Event):void
        {
            var bmp:Bitmap = e.currentTarget as Bitmap;
            bmp.alpha += 0.05;
            if(bmp.alpha >= 1) {
                bmp.alpha = 1;
                bmp.removeEventListener(Event.ENTER_FRAME, bmpFadeIn);
                if(lastPhoto) {
                    container.removeChild(lastPhoto);
                    lastPhoto.bitmapData.dispose();
                }
                lastPhoto = bmp;
            }
        }
        
        private function bmpFadeOut(e:Event):void
        {
            var bmp:Bitmap = e.currentTarget as Bitmap;
            bmp.alpha -= 0.05;
            if(bmp.alpha <= 0) {
                bmp.alpha = 0;
                bmp.removeEventListener(Event.ENTER_FRAME, bmpFadeOut);
                container.removeChild(bmp);
                lastPhoto = null;
            }
        }        
    }
}


class GMStandard
{
    public static const percussion:Array = new Array();
    {
        //GM1
        percussion[35] = "BassDrum2";
        percussion[36] = "BassDrum1";
        percussion[37] = "SideStick";
        percussion[38] = "SnareDrum1";
        percussion[39] = "HandClap";
        percussion[40] = "SnareDrum2";
        percussion[41] = "LowTom2";
        percussion[42] = "ClosedHiHat";
        percussion[43] = "LowTom1";
        percussion[44] = "PedalHiHat";
        percussion[45] = "MidTom2";
        percussion[46] = "OpenHiHat";
        percussion[47] = "MidTom1";
        percussion[48] = "HighTom2";
        percussion[49] = "CrashCymbal1";
        percussion[50] = "HighTom1";
        percussion[51] = "RideCymbal1";
        percussion[52] = "ChineseCymbal";
        percussion[53] = "RideBell";
        percussion[54] = "Tambourine";
        percussion[55] = "SplashCymbal"; 
        percussion[56] = "Cowbell";
        percussion[57] = "CrashCymbal2";
        percussion[58] = "VibraSlap";
        percussion[59] = "RideCymbal2";
        percussion[60] = "HighBongo";
        percussion[61] = "LowBongo";
        percussion[62] = "MuteHighConga";
        percussion[63] = "OpenHighConga";
        percussion[64] = "LowConga";
        percussion[65] = "HighTimbale";
        percussion[66] = "LowTimbale";
        percussion[67] = "HighAgogo";
        percussion[68] = "LowAgogo";
        percussion[69] = "Cabasa";
        percussion[70] = "Maracas";
        percussion[71] = "ShortWhistle";
        percussion[72] = "LongWhistle";
        percussion[73] = "ShortGuiro";
        percussion[74] = "LongGuiro";
        percussion[75] = "Claves";
        percussion[76] = "HighWoodBlock";
        percussion[77] = "LowWoodBlock";
        percussion[78] = "MuteCuica";
        percussion[79] = "OpenCuica";
        percussion[80] = "MuteTriangle";
        percussion[81] = "OpenTriangle";
        
        //GM2
        percussion[27] = "HighQ";
        percussion[28] = "Slap";
        percussion[29] = "ScratchPush";
        percussion[30] = "ScratchPull";
        percussion[31] = "Sticks";
        percussion[32] = "SquareClick";
        percussion[33] = "MetronomeClick";
        percussion[34] = "MetronomeBell";
        percussion[34] = "MetronomeBell";
        
        percussion[82] = "Shaker";
        percussion[83] = "JingleBell";
        percussion[84] = "BellTree";
        percussion[85] = "Castanets";
        percussion[86] = "MuteSurdo";
        percussion[87] = "OpenSurdo";
    }
}