AS3を使用してフラッシュでクイズを作成しています。ユーザーが正しいか間違った答えをクリックしたときに音を鳴らすのに問題があります。ユーザーが正しい回答をクリックしたときにサウンドを再生する方法
サウンドを正しく再生するにはどうすればよいですか?
これは
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");
}
私はこれを試してみました。私はこれを正しくしましたか? –
あなたの活動名は何ですか?私はちょうどYourActivityを無作為に保った!あなたのアクティビティ名を書く必要があります、クラス名 –
@TripatheeGaurav、これはAndroid SDKコードですか? AskerはAS3(Flash)コードを使用してAndroidアプリを作成しています。 –