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

音階を奏でてみる

SiONの練習を兼ねて、ひとまず(ドからドまでの)音階を奏でてみる。
Get Adobe Flash player
by flabaka 30 Dec 2010
/**
 * Copyright flabaka ( http://wonderfl.net/user/flabaka )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2oyL
 */

package 
{
    import com.bit101.components.PushButton;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import org.si.sion.SiONData;
    import org.si.sion.SiONDriver;
    
    [SWF (width="465",height="465",backgroundColor="0xFFFFFF",frameRate="30")]
    /**
    * ...
    * @author flabaka
    */
    
    public class Main extends Sprite 
    {
        private var driver:SiONDriver;
        private var musicData:SiONData;
        private var btn:PushButton;
        
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            
            btn = new PushButton();
            btn.label = "CLICK!";
            btn.x = (stage.stageWidth / 2) - (btn.width / 2);
            btn.y = (stage.stageHeight / 2) - btn.height;
            addChild(btn);
            
            driver = new SiONDriver();
            musicData = driver.compile("t100 @v32 18 o5 cdefgab o6 cc o5 bagfedc");
            btn.addEventListener(MouseEvent.CLICK, clickHandler);
        }
        
        private function clickHandler(e:MouseEvent):void 
        {
            driver.play(musicData);
        }
    }
}