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: カムラス (オルハの笛)

SiON Test
*
* Music is from:
* Cumulus (Olha's Flute) 
* The Songs of Zemeth
* Copyright© Nihon Falcom Corporation
/**
 * Copyright mirkofresa ( http://wonderfl.net/user/mirkofresa )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lKQr
 */

// forked from civet's カムラス (オルハの笛)
/**
 * SiON Test
 *
 * Music is from:
 * Cumulus (Olha's Flute) 
 * The Songs of Zemeth
 * Copyright© Nihon Falcom Corporation
 */
package {
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
   
    import org.si.sion.SiONData;
    import org.si.sion.SiONDriver;
    import org.si.sion.events.SiONTrackEvent;
    import org.si.sion.utils.SiONPresetVoice;
    
    public class OLHA extends Sprite
    {
        public function OLHA()
        {
            //1. proxy?
            //var loader:Loader = new Loader();
            //loader.load(new URLRequest("http://www.falcom.co.jp/download/w_paper/ys/pc_wp/ys6_08s.jpg"));
            //addChild(loader);
            
            //2. load external images without crossdomain.xml
            //ref: http://wonderfl.net/code/5c164cb968b9883d1eee01b236c5206956e57545
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function():void { } );
            loader.load(new URLRequest("http://sites.google.com/site/phresacorp/programming.jpg"));
            
            //BGM
            playMusic();
        }
        
        private function onInit(event:Event):void
        {
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.INIT, onInit2);
            loader.loadBytes(event.currentTarget.bytes)
        }
        
        private function onInit2(event:Event):void
        {
            this.addChild(event.currentTarget.content);
        }
       
        private function playMusic():void
        {
            var mml:String = "#REV; #EFFECT0{delay300,32,1};";
            mml += "%t0,1,0 ";
            mml += "%6@0 ";
            mml += "t125v15>>dggaf2.r16<g>d1.rl8cdc<a+b+2l4ga+a>cdfd1.rdggaf2.r16<g>d1.rl8cdc<a+b+2l4ga+a>cdfg1a1.rg2>dl8c<a+a2.gag4d4fedcd2.gaa+2.>cdc2<a4a+ag4f2dcd2.r4g2>d4c<a+a2.gag4d4fedcd2.<gaa+2.>cdc2l4.fag2.fg1";
            mml += ";";
            //Driver
            var driver:SiONDriver = new SiONDriver();
            driver.addEventListener(SiONTrackEvent.NOTE_ON_FRAME, onNoteOn);
           
            var presetVoice:SiONPresetVoice = new SiONPresetVoice();
            var data:SiONData = driver.compile(mml);
            data.setVoice(0, presetVoice["midi.pipe4"]);
           
            driver.play(data);
        }
        
        private function onNoteOn(e:SiONTrackEvent):void
        {
            createNoteShape(e.note);
        }
        
        private function createNoteShape(noteNumber:int):void
        {
            var shape:Shape = new Shape();
            shape.graphics.beginFill(0xFFFFFF);
            shape.graphics.drawCircle(0, 0, Math.random() * 14 + 2);
            shape.graphics.endFill();
            shape.x = (noteNumber - 60) * 16 - 64;
            shape.y = stage.stageHeight;
            shape.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            this.addChild(shape);
        }
        
        private function onEnterFrame(e:Event):void
        {
	    var target:DisplayObject = e.currentTarget as DisplayObject;
	    target.y -= 4;
            target.alpha -= 0.02;
            if(target.alpha < 0.1) {
                target.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
                this.removeChild(target);
            }
        }
    }
}