※ [AS2] 按 1‧2‧3‧4‧5‧6‧7‧8 鍵‧播放音階 --- 基本作法
※ 第一影格AS2
//將音階聲音檔匯入元件庫中,並設定連結名稱......
//
var mySound:Sound=new Sound();
//按12345678鍵‧播放音階
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(49)||Key.isDown(97)) {
mySound.attachSound("1.mp3")
mySound.start();
}
if (Key.isDown(50)||Key.isDown(98)) {
mySound.attachSound("2.mp3")
mySound.start();
}
if (Key.isDown(51)||Key.isDown(99)) {
mySound.attachSound("3.mp3")
mySound.start();
}
if (Key.isDown(52)||Key.isDown(100)) {
mySound.attachSound("4.mp3")
mySound.start();
}
if (Key.isDown(53)||Key.isDown(101)) {
mySound.attachSound("5.mp3")
mySound.start();
}
if (Key.isDown(54)||Key.isDown(102)) {
mySound.attachSound("6.mp3")
mySound.start();
}
if (Key.isDown(55)||Key.isDown(103)) {
mySound.attachSound("7.mp3")
mySound.start();
}
if (Key.isDown(56)||Key.isDown(104)) {
mySound.attachSound("8.mp3")
mySound.start();
}
}
Key.addListener(keyListener);
SWF瀏覽
http://sites.google.com/site/terfict3/home/981015_as2_sound_key.swf
FLA
http://sites.google.com/site/terfict3/home/981015_as2_sound_key.rar
鍵碼值請參考這篇~
[使用key類別的getCode()和getAscii()方法,傳回最後所按下按鍵的鍵碼值 ]
http://terfict.blogspot.com/2009/12/keygetcodegetascii.html
2009年12月27日 星期日
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言