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: How to give slide effect in guitar

Get Adobe Flash player
by shohei909 27 Mar 2011
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pcXF
 */

// forked from UtilZone's How to give slide effect in guitar
package {
    import flash.display.Sprite;
    import flash.events.*;
    import com.bit101.components.*;
    import org.si.sion.*;
    import org.si.sion.sequencer.SiMMLTrack;
    import org.si.sion.utils.SiONPresetVoice;

    public class FlashTest extends Sprite {
        private var track:SiMMLTrack;
        private var driver:SiONDriver;
        private var presetVoice:SiONPresetVoice;
        private var voice:SiONVoice;
        private var envelopData:Array = [
            Vector.<int>([]),
            Vector.<int>([0,1,2,3,4,5]),
            Vector.<int>([5,4,3,2,1,0]),
            Vector.<int>([0,2,4,6,8,6,4,2,0])
        ]
        public function FlashTest() {
           driver = new SiONDriver();
           presetVoice = new SiONPresetVoice();
           voice = new SiONVoice();
           voice = presetVoice["valsound.guitar"][1];
           
           driver.setVoice(0, voice);
           for(var i:int=1;i<4;i++ ){
               driver.setEnvelopTable(i, envelopData[i]);
           }
           
           driver.setSamplerData(0, driver.render("%6@0 c8d8e8") );//sound0
           driver.setSamplerData(1, driver.render("%6@0 nt1 c8d8e8") );//sound1
           driver.setSamplerData(2, driver.render("%6@0 nt2 e8d8c8") );//sound2
           driver.setSamplerData(3, driver.render("%6@0 nt3 ed8c8") );//sound3
           
           
           driver.play();

            var btn:PushButton;
            
           //sound0
            btn = new PushButton(this);
            btn.label = "sound0";
            btn.x = 10;
            btn.y = 10
            btn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
                driver.playSound(0);
            }); 
            
           //sound1
            btn = new PushButton(this);
            btn.label = "sound1";
            btn.x = 10;
            btn.y = 40;
            btn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
                driver.playSound(1);
            }); 
            
           //sound2
            btn = new PushButton(this);
            btn.label = "sound2";
            btn.x = 10;
            btn.y = 70;
            btn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
                driver.playSound(2);
            }); 
            
           //sound3
            btn = new PushButton(this);
            btn.label = "sound3";
            btn.x = 10;
            btn.y = 100;
            btn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
                driver.playSound(3);
            }); 
            
        }
    }
}