カムラス (オルハの笛)
SiON Test
*
* Music is from:
* Cumulus (Olha's Flute)
* The Songs of Zemeth
* Copyright© Nihon Falcom Corporation
/**
* Copyright civet ( http://wonderfl.net/user/civet )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/Adqk
*/
/**
* SiON Test
*
* Music is from:
* Cumulus (Olha's Flute)
* The Songs of Zemeth
* Copyright© Nihon Falcom Corporation
* 2013-05-21 15:38:42
*/
package {
import flash.system.LoaderContext;
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://www.falcom.co.jp/download/w_paper/ys/pc_wp/ys6_08s.jpg"));
//not work now, FlashPlayer BUG fixed
*/
//3. same domain
var loader:Loader = new Loader();
loader.load(new URLRequest("http://assets.wonderfl.net/images/related_images/0/0b/0baa/0baa9c06055b8a76a93c57d69e3b8b5251a7f634"), new LoaderContext(true));
this.addChild(loader);
//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);
}
}
}
}