Forked from: kotobuki's Simple Sound Player diff:10 Simple Sound Player: Physical Button kotobuki forked:2favorite:0lines:26license : MIT License modified : 2009-09-08 22:41:34 Embed Tweet // forked from kotobuki's Simple Sound Player package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.media.Sound; import flash.net.URLRequest; import funnel.*; import funnel.ui.*; public class SimpleSoundPlayer extends Sprite { // これはMac OS Xの場合にはパーソナルウェブ共有、Windowsの場合には // AN HTTPDなどを使用してローカルでサーバを用意することを想定した // URLです。 private const URL_OF_SOUND_FILE:String = "http://localhost/sounds/snare.mp3"; private var _sound:Sound; private var _gainer:Gainer; public function SimpleSoundPlayer() { _sound = new Sound(); _sound.addEventListener(Event.COMPLETE, onLoadComplete); _sound.load(new URLRequest(URL_OF_SOUND_FILE)); _gainer = new Gainer(); } private function onLoadComplete(e:Event):void { // サンプルのロードが完了したらボタンプレスで再生するように // イベントリスナをセットする _gainer.button.addEventListener(ButtonEvent.PRESS, onButtonPress); } private function onButtonPress(e:ButtonEvent):void { // MP3にエンコードした時に頭に空白が入ってしまうため // スタートポイントを30ms後にしてレスポンスを改善する _sound.play(30); } } } Code Fullscreen Preview Fullscreen gainer physical Sound load play MouseEvent.COMPLETE addEventListener URLRequest String Sprite sort new page view favorite forked pv858 Simple Sound Player: Photo Ref.. kotobuki forked:4 favorite:0lines:43 (diff:41) tag: gainer physical pv1747 Simple Sound Player: Accelerom.. kotobuki forked:9 favorite:0lines:47 (diff:42) tag: gainer physical