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

Bad Apple!! ?_?

2009-11-10
Get Adobe Flash player
by civet 08 Jan 2016
/**
 * Copyright civet ( http://wonderfl.net/user/civet )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zlJ5
 */

//modified : 2009-11-10 23:21:55
package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.system.Security;
    
    import org.si.sion.SiONData;
    import org.si.sion.SiONDriver;
    import org.si.sion.SiONVoice;
    import org.si.sion.events.SiONTrackEvent;
    import org.si.sion.utils.SiONPresetVoice;
    
    public class Main extends Sprite
    {
        public function Main()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            graphics.beginFill(0);
            graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            graphics.endFill();
            Security.loadPolicyFile("http://dreamana.com/crossdomain.xml");
            init();
        }
        
        private var PATH:String = "http://dreamana.com/lab/sion/";
        private var driver:SiONDriver;
        private var bound:Rectangle;
        private var center:Point;
        private var status:TextField;
        
        private function init():void
        {
            bound = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            center = new Point(int(stage.stageWidth/2), int(stage.stageHeight/2));
            
            //Driver
            driver = new SiONDriver();
            
            //Status
            status = new TextField();
            status.defaultTextFormat = new TextFormat("_sans", 36, 0xffffff);
            status.autoSize = TextFieldAutoSize.LEFT;
            status.text = "少女祈祷中???";
            status.x = stage.stageWidth - status.width;
            status.y = stage.stageHeight - status.height;
            addChild(status);
            
            //SamplerSounds for percussion
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
            loader.load(new URLRequest(PATH + "TR909.swf"));
        }
        
        private function onLoadComplete(e:Event):void
        {
            removeChild(status);
            var loaderInfo:LoaderInfo = e.currentTarget as LoaderInfo;
            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);
            }
            //play after SamplerSounds loaded            
            playMML();
        }
                        
        private function playMML():void
        {
            //MML(ref: http://mabimml.modev.jp/index.cgi?sep=12497)
            var mml:String = "#REV; t138"
                + "%t0,1,0 %6@0 v8"
                + "l8d+>d+l16<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+f+<f+8>f+g+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+g+8f+g+f+8c+d+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+f+<f+8>f+g+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+<d+8>d+8<d+>d+c+d+l12g+f+g+f+c+d+v10l8d+ff+g+a+4>d+c+<a+rd+ra+g+f+fd+ff+g+a+4g+f+fd+ff+fd+dfd+ff+g+a+4>d+c+<a+rd+ra+g+f+fd+ff+g+a+4g+f+frf+rg+ra+r>c+d+<a+g+a+4g+a+>c+d+<a+g+a+4g+a+g+f+fc+d+4c+d+ff+g+a+d+4a+>c+c+d+<a+g+a+4g+a+>c+d+<a+g+a+4g+a+g+f+fc+d+4c+d+ff+g+a+d+4a+>c+c+d+<a+g+a+4g+a+>c+d+<a+g+a+4g+a+g+f+fc+d+4c+d+ff+g+a+d+4a+>c+c+d+<a+g+a+4g+a+>c+d+<a+g+a+4>d+ff+fd+c+<a+4g+a+g+f+fc+d+4b>dde<bab4ab>de<bab4abagf+de4def+gabe4b>dde<bab4ab>de<bab4>ef+gf+ed<b4abagf+de4.;"
                + "%t1,1,0 %6@0 v8"
                + "r2l1.r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c+d+<a+g+a+4g+a+>c+d+<a+g+a+4g+a+g+f+fc+d+4c+d+ff+g+a+d+4a+>c+c+d+<a+g+a+4g+a+>c+d+<a+g+a+4g+a+g+f+fc+d+4c+d+ff+g+a+d+4a+>c+c+d+<a+g+a+4g+a+>c+d+<a+g+a+4>d+ff+fd+c+<a+4g+a+<g+f+fc+d+4>b>dde<bab4ab>de<bab4abagf+de4def+gabe4b>dde<bab4ab>de<bab4>ef+gf+ed<b4abagf+de4.;"
                + "%6@1 v8"
                + "r2l1.rrrrrl1o6d+&d+c-c+2d2d+&d+v8l8o3f+g+a+>c+d+4c+<a+g+ra+r>c+rd+rff+d+c+d+4c+d+ff+d+c+d+4c+d+c+<a+g+ff+4ff+g+a+>c+d+<f+4>d+fff+d+c+d+4c+d+ff+d+c+d+4c+d+c+<a+g+ff+4ff+g+a+>c+d+<f+4>d+fff+d+c+d+4c+d+ff+d+c+d+4c+d+c+<a+g+ff+4ff+g+a+>c+d+<f+4>d+fff+d+c+d+4c+d+ff+d+c+d+4f+g+a+g+f+fd+4c+d+r2.ef+f+gede4def+gede4ded<baf+g4f+gab>de<g4>ef+f+gede4def+gede4gabagf+e4ded<baf+g4.;"
                + "%6@1 v8"
                + "r2l1.rrrrrl8<f+g+a+>c+d+4f+fd+r<f+>rd+c+<a+g+f+g+a+>c+d+4c+<a+g+f+g+a+g+f+fg+f+g+a+>c+d+4f+fd+r<f+>rd+c+<a+g+v10l1>>b>c+2d2c-c+d+d+2.c+4c-c+d+d+2.c+4c-c+d+d+2.c+4c-c+d+rcdee2.d4cdel8d<baf+g4.;"
                + "%6@0 v8"
                + "<l16<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+<d+8>d+f+<f+8>f+g+<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+g+8f+g+f+8c+d+<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+<d+8>d+8.d+c+d+<d+8>d+f+<f+8>f+g+<d+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v1l48a+a+a+v2a+a+a+v3a+a+a+v4a+a+a+v5a+a+a+v6a+a+a+v7a+a+a+v8a+a+a+v9a+a+v10a+a+v11a+a+v12a+a+v13a+a+v14a+a+v15a+1.;"
                + "%t3,1,0 %10 v12"
                + "o3l8arararararararaaarararararararaaarararararararaaararararararl12aaaaaal8arararararararaaararararararaaararararararararaaarararararararararararararararaaararararararaaararararararararaaararararararl12aaaaaal8arararl16aaaal8arararaaarararl16aaaal8araraaararararl16aaaal8arararaaararararv13a4r2.v15a4rr2aa4r2.a4rr2aa4r2.a4rr2aa4rr2aar4aar4aar4aarara1.;"
                ;
            var data:SiONData = driver.compile(mml);
            var presetVoice:SiONPresetVoice = new SiONPresetVoice();
            var voice0:SiONVoice = presetVoice["valsound.piano14"];
            var voice1:SiONVoice = presetVoice["valsound.piano17"];
            data.setVoice(0, voice0);
            data.setVoice(1, voice1);
            
            driver.addEventListener(SiONTrackEvent.NOTE_ON_FRAME, onNoteOn);
            driver.play(data);
        }
        
        private function onNoteOn(e:SiONTrackEvent):void
        {
            switch(e.eventTriggerID) {
                case 0: createBullet(0xff0000, e.note-60); break;
                case 1: createBullet(0x00ff00, e.note-60); break;
                case 2: createBullet(0x0000ff, e.note-60); break;
                case 3: createWave(0x00ccff); break;    
            }
        }
                
        private function createBullet(color:uint, note:int):void
        {
            var b:Bullet = new Bullet(color);
            b.x = center.x;
            b.y = center.y - 100;
            b.vx = Math.cos(Math.PI / 18 * note) * 4;
            b.vy = Math.sin(Math.PI / 18 * note) * 4;
            addChild(b);
            b.addEventListener(Event.ENTER_FRAME, onBulletEnterFrame);
        }
        
        private function createWave(color:uint):void
        {
            var w:Wave = new Wave(color);
            w.x = center.x;
            w.y = center.y - 100;
            w.vx = 0.6;
            w.vy = 0.6;
            addChild(w);
            w.addEventListener(Event.ENTER_FRAME, onWaveEnterFrame);
        }
        
        private function onBulletEnterFrame(e:Event):void
        {
            var target:Bullet = e.currentTarget as Bullet;
            target.update();
            if(target.x < bound.left || target.y < bound.top || target.x > bound.right || target.y > bound.bottom) {
                target.removeEventListener(Event.ENTER_FRAME, onBulletEnterFrame);
                target.parent.removeChild(target);
            }
        }
                
        private function onWaveEnterFrame(e:Event):void
        {
            var target:Wave = e.currentTarget as Wave;
            target.update();
            if(target.alpha < 0.1) {
                target.removeEventListener(Event.ENTER_FRAME, onWaveEnterFrame);
                target.parent.removeChild(target);
            }
        }
        
    }
}

import flash.display.Sprite;
class Bullet extends Sprite {
    public var vx:Number = 0;
    public var vy:Number = 0;
    public function Bullet(borderColor:uint) {
        this.graphics.lineStyle(2, borderColor);
        this.graphics.beginFill(0xffffff);
        this.graphics.drawCircle(0, 0, 10);
        this.graphics.endFill();
    }
    public function update():void {
        this.x += vx;
        this.y += vy;
    }
}

import flash.display.Sprite;
class Wave extends Sprite {
    public var vx:Number = 0;
    public var vy:Number = 0;
    public function Wave(borderColor:uint) {
        this.graphics.lineStyle(1, borderColor);
        this.graphics.drawCircle(0, 0, 10);
        this.graphics.endFill();
    }
    public function update():void {
        this.scaleX += vx;
        this.scaleY += vy;
        this.alpha -= 0.02;
    }
}

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";
    }
}