Convert code to html5 canvas

Participant ,
May 22, 2020

Copy link to clipboard

Copied

import flash.utils.Timer;

 

var n, s;
var a: Array = new Array();
var t: Timer = new Timer(5000);

a[0] = ["q1", true, ""];
a[1] = ["q2", false, "Answer1"];
a[2] = ["q3", false, "Answer2"];
a[3] = ["q4", true, ""];
a[4] = ["q5", false, "Answer4"];
a[5] = ["q6", true, ""];
a[6] = ["q7", false, "Answer7"];
a[7] = ["q8", true, ""];
a[8] = ["q9", false, "Answer9"];
a[9] = ["q10", true, ""];

t = 0;

rndq();

ff();

next.addEventListener(MouseEvent.CLICK, nx);
right.addEventListener(MouseEvent.CLICK, rt);
wrong.addEventListener(MouseEvent.CLICK, wr);
t.addEventListener(TimerEvent.TIMER, fin);

 


// ----------------- next button ---------------
function nx(e: MouseEvent): void {
right.visible = true;
wrong.visible = true;
n++;
t++;
qn.text = n;
q.text = a[n - 1][0];
//qr.text=a[n-1][2];
if (n == a.length) {
next.removeEventListener(MouseEvent.CLICK, nx);
next.enabled = false;
}
t.reset();
t.start();
f_txt.text = "start";
//t.text = play();
}

// --------- rihgt butoon ------------------
function rt(e: MouseEvent): void {
right.visible = false;
wrong.visible = false;

if (a[n - 1][1] == true) {
s++;
Answer.text = a[n - 1][2];
score.text = s;
}
t.stop();
//t.text = stop();
}


// --------- Worng Button -----------------
function wr(e: MouseEvent): void

{
right.visible = false;
wrong.visible = false;


if (a[n - 1][1] == false) {
s++;
Answer.text = a[n - 1][2];
score.text = s;

}
t.stop();
//t.text = stop();
}

//------------- RND Questatios -----------

function rndq(): void {
var b: Array = new Array();
var c: Array = new Array();
var r, rnd;
for (r = 0; r < 7; r++) {
rnd = Math.round(Math.random() * (a.length - 1));
b = a.splice(rnd, 1);
c[r] = b[0];
}
a = c;
}


// -----------First q -----------
function ff(): void {

n = 1;

qn.text = n;
Answer.text = "";
q.text = a[0][0][0];
s = 0;
score.text = s;
t.start();
}

// --------- time finish ---------
function fin(e: TimerEvent): void {
if (t == 10) {
f_txt.text = "over time";
right.visible = false;
wrong.visible = false;
} else {
t++;
}
}

 

Views

103

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Have something to add?

Join the conversation