Technology
SiONを鳴らす
2010-08-29ActionScript
音を鳴らす
importでsionのライブラリをロードしています。また、addEventListenerでtextFieldをクリックしたら、play関数が呼ばれるようにしています。
package { import flash.display.Sprite; import org.si.sion.*; import flash.text.*; import flash.events.*; public class Main extends Sprite { public var driver:SiONDriver = new SiONDriver(); private var textField:TextField; function Main() { textField = new TextField(); textField.x = 100; textField.y = 50; textField.background=true; textField.backgroundColor=0xCCCCCC; textField.text = "Play the ABCSong"; textField.addEventListener(MouseEvent.CLICK, play); addChild(textField); } private function play(s:String):void{ driver.play("t100 l8 [ccggaag4 ffeeddc4 | [ggffeed4]2 ]2"); } } }
TextFieldの値を鳴らす
textFieldの値をplay関数の引数に渡しているだけです。
package { import flash.display.Sprite; import org.si.sion.*; import flash.text.*; import flash.events.*; public class Main extends Sprite { public var driver:SiONDriver = new SiONDriver(); private var textField:TextField; private var button:TextField; function Main() { textField = new TextField(); textField.x = 0; textField.y = 0; textField.width=300; textField.height=100; textField.border=true; textField.borderColor=0xDDDDDD; textField.background=true; textField.backgroundColor=0xEEEEEE; textField.text = "Hello, world!!"; textField.type = TextFieldType.INPUT; textField.multiline=true; textField.wordWrap=true; addChild(textField); button = new TextField(); button.x = 0; button.y = 120; button.width=100; button.height=30; button.border=true; button.borderColor=0x111111; button.background=true; button.backgroundColor=0x333333; button.textColor=0xEEEEEE; button.text = "Play"; button.type = TextFieldType.DYNAMIC; button.addEventListener(MouseEvent.CLICK, play); addChild(button); } private function play(s:String):void{ driver.play(textField.text); } } }
Topic
- Languages (24)
- ActionScript (8)
- C# (1)
- Java (6)
- Android (2)
- JavaScript (5)
- JavaScript (4)
- node.js (1)
- Perl (4)
- Database (3)
- MySQL (3)
- Miscellaneous (5)