我正在使用 AS3 在 Flash 中创建一个测验。当用户单击正确或错误的答案时,我无法尝试包含声音。
如何正确播放声音?
这是下面的代码
import flash.media.Sound;
//button 1, see if the first text field equals the answer, if it does it plays the correct scene, if it doesnt it plays incorrect scene
myTextField11.addEventListener(MouseEvent.MOUSE_UP,state11);
function state11(evt:MouseEvent)
{
if (myTextField11.text == answer1){
trace("Correct answer!!");
gotoAndPlay(2,"quiz1");
count = count + 10;
scoreBox.text = (count).toString();
setTimeout(gotoAndPlay, 1250, 1, "quiz2");
} else {
trace(myTextField11);
gotoAndPlay(3,"quiz1");
var mySound:Sound = new WrongAnswer();
WrongAnswer.play();
setTimeout(gotoAndPlay, 1250, 1,"quiz2");
}
}
我现在已经做到了,但没有运气:
import flash.media.Sound;
//button 1, see if the first text field equals the answer, if it does it plays the correct scene, if it doesnt it plays incorrect scene
myTextField11.addEventListener(MouseEvent.MOUSE_UP,state11);
function state11(evt:MouseEvent)
{
if (myTextField11.text == answer1){
trace("Correct answer!!");
gotoAndPlay(2,"quiz1");
count = count + 10;
scoreBox.text = (count).toString();
setTimeout(gotoAndPlay, 1250, 1, "quiz2");
} else {
trace(myTextField11);
gotoAndPlay(3,"quiz1");
MediaPlayer player = MediaPlayer player=MediaPlayer.create(YourActivity.this,R.raw.WrongAnswer);
player.start();
setTimeout(gotoAndPlay, 1250, 1,"quiz2");
}