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: flash on 2010-3-7

Get Adobe Flash player
by 1031no 07 Mar 2010
/**
 * Copyright 1031no ( http://wonderfl.net/user/1031no )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/viTA
 */

// forked from 1031no's flash on 2010-3-7
package {
    import flash.display.Sprite;
    import flash.events.*;
    import com.bit101.components.*;
    import org.si.sion.*;
    import org.si.sion.utils.SiONPresetVoice;
    [SWF(width = "300", height = "150", backgroundColor = "#FFFFFF")]
    public class PlayWithPreseVoicet extends Sprite {
        // SiONDriverクラスのインスタンスを生成
        public var driver:SiONDriver = new SiONDriver();
        // SiONPresetVoiceクラスのインスタンスを生成
        public var presetVoice:SiONPresetVoice = new SiONPresetVoice();
        // SiONVoice型変数を宣言
        public var voice1:SiONVoice;
        public var voice2:SiONVoice;
        // SiONData型変数を宣言
        public var mainMelody:SiONData;
        function PlayWithPreseVoicet() {
		//MMLをSiONData型にコンパイル
            mainMelody    = driver.compile("t200 I1 [c1]")
            //SiONVoice型変数にプリセットボイスを設定
            voice1 = presetVoice["valsound.bell16"];
            voice2 = presetVoice["valsound.wind1"];
            //ボタンコンポーネント(ボタン1、2)
			new PushButton(this,  20, 50, "Button1-piano8", _play_preset1);
            new PushButton(this, 170, 50, "Button2-wind1", _play_preset2);
            driver.play();
        }
        // ボタン1のアクション
        private function _play_preset1(e:MouseEvent) : void {
			// 第一引数にSiONData、第二引数にSiONVoice、第三引数以降は、length=0(play all of sequence), delay=0(no delay), quantize=2(8th beat)
            driver.sequenceOn(mainMelody, voice1, 0, 0, 2);
        }
		// ボタン2のアクション
         private function _play_preset2(e:MouseEvent) : void {
			 // ボタン1と同じでプリセットボイスのみ違う
            driver.sequenceOn(mainMelody, voice2, 0, 0, 2);
        }
    }
}