why the score doesn't appear or even increase , Adobe Animate, HTML5, Javascript
I create an quiz using html5 canvas in Adobe Animate
if click on the correct answer, it will increase the score to 10
but in my project it's not working i'm a new in adobe animate
here variabel I'm use :
var data = [{
pertanyaan_text: "Berapakah Jenis Bekam",
jawaban_benar: "1",
pilihan_jawaban: ["1", "2", "3","4"]
}, {
pertanyaan_text: "Bekam yang dilakukan dengan memberikan perlukaan disebut",
jawaban_benar: "1",
pilihan_jawaban: ["Bekam Kering", "Bekam Basah", "Bekam Luncur","Bekam Pijat"]
}, {
pertanyaan_text: "Salah satu Kontraindikasi Absolut Bekam adalah",
jawaban_benar: "0",
pilihan_jawaban: ["Hemofilia", "Hipertensi", "Anak-anak","Sakit Kepala"]
}, ];
var indexPertanyaan = 0;
var currentPertanyaan;
var score = 0;
var IsAnswer=false;
and here the function to load the question and answer , they are willbe randomizing
function loadPertanyaan(e){
//randomizing question
data= mixed(data);
//First Question
currentPertanyaan = data[indexPertanyaan];
//load the question
this.mc_kuis.txt_Pertanyaan.text = currentPertanyaan.pertanyaan_text;
//Randomizing the answer dan load to button
var acakJawaban = mixed(currentPertanyaan.pilihan_jawaban);
this.mc_kuis.bt_jawaban1.txt_Jawaban.text = acakJawaban[0];
this.mc_kuis.bt_jawaban2.txt_Jawaban.text = acakJawaban[1];
this.mc_kuis.bt_jawaban3.txt_Jawaban.text = acakJawaban[2];
this.mc_kuis.bt_jawaban4.txt_Jawaban.text = acakJawaban[3];
}
here the function for the score :
this.mc_kuis.bt_jawaban1.on("click",onClickAnswer.bind(this));
this.mc_kuis.bt_jawaban2.on("click",onClickAnswer.bind(this));
this.mc_kuis.bt_jawaban3.on("click",onClickAnswer.bind(this));
this.mc_kuis.bt_jawaban4.on("click",onClickAnswer.bind(this));
function onClickAnswer(e)
{
if(IsAnswer==true)
{
var item=e.currentTarget;
if(item.name=="jawaban_benar"+currentPertanyaan.jawaban_benar)
{
score+=10;
this.text_skor.text=score;
console.log(score);
}else{
console.log("Incorrect");
}
IsAnswer=false;
}
NextQuestion.bind(this)();
console.log(onClickAnswer);
}
function NextQuestion(e)
{
indexPertanyaan++;
if(indexPertanyaan == data.length)
{
this.gotoAndStop("LB_HasilKuis")
}else{
currentPertanyaan=data[indexPertanyaan];
loadPertanyaan.bind(this)();
}
}
When I'm debugging , it's like the button all false or it 's like just a button and the score not increase
Thank you for Helping me, and sorry confused you all and it seems like I often make discussions because I am still very new and confused.
