this was for a client that wanted a 'identify the flag' quiz:
this.stop();
this.name = 'main TL';
this.maxIncorrectA = [3,2,1,1,1];
this.nomsPays = ["nomsPaysAfrique","nomsPaysAmerique","nomsPaysAsie","nomsPaysEurope","nomsPaysOceanie"];
this.flags = ["flagsOfAfrica","flagsOfAmerica","flagsOfAsia","flagsOfEurope","flagsOfOceania"];
this.index = -1;
//////////////////////////////////////////////////////////////////////
// 1) une var nommée nomsPaysAfrique pour mettre tous les drapeaux d'Afrique
this.nomsPaysAfrique = ["AFRIQUE DU SUD", "BÉNIN", "BURKINA FASO", "CAMEROUN", "CONGO", "CONGO RÉP.DÉM.ZAÏRE", "CÔTE D'IVOIRE", "ÉGYPTE",
"GHANA", "GUINÉE", "GUINÉE ÉQUATORIALE", "ÎLE MAURICE", "KÉNYA", "LESOTHO", "MADAGASCAR", "MALAWI", "MALI", "NIGÉRIA", "OUGANDA",
"RWANDA", "SÉNÉGAL", "SOMALIE", "TANZANIE", "TCHAD", "TOGO", "ZAMBIE"];
// 1a) une var nommée flagsOfAfrica afin de faire disparaître tous les drapeaux concernés, après 3 mauvais essais
this.flagsOfAfrica = ["afriqueDuSud1", "benin1", "burkinaFaso1", "cameroun1", "congo1", "congoRepDemZaire1", "coteIvoire1", "egypte1",
"ghana1", "guinee1", "guineeEquatoriale1", "ileMaurice1", "kenya1", "lesotho1", "madagascar1", "malawi1", "mali1", "nigeria1", "ouganda1",
"rwanda1", "senegal1", "somalie1", "tanzanie1", "tchad1", "togo1", "zambie1"];
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// 2) une var nommée nomsPaysAmerique pour mettre tous les drapeaux d'Amérique
this.nomsPaysAmerique = ["ARGENTINE","BOLIVIE","BRÉSIL","CANADA","CHILI","COLOMBIE",
"COSTA RICA","CUBA","EL SALVADOR","ÉQUATEUR","ÉTATS UNIS","GUATEMALA","GUYANE","HAÏTI","HONDURAS","MEXIQUE","PARAGUAY",
"PÉROU","RÉP. DOMINICAINE","URUGUAY"];
this.flagsOfAmerica = ["argentine1","bolivie1","bresil1","canada1","chili1","colombie1",
"costaRica1","cuba1","elSalvador1","equateur1","etatsUnis1","guatemala1","guyane1","haiti1","honduras1","mexique1","paraguay1",
"perou1","repDominicaine1","uruguay1"];
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// 3) une var nommée nomsPaysAsie pour mettre tous les drapeaux d'Asie
this.nomsPaysAsie = ["BAHREIN","BANGLADESH","CHINE","INDE","IRAK","JAPON","KOWEIT","LIBAN","PHILIPPINES","SYRIE","TAÏWAN","VIETNAM"];
this.flagsOfAsia = ["bahrein1","bangladesh1","chine1","inde1","irak1","japon1","koweit1","liban1","philippines1","syrie1","taiwan1","vietnam1"]
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// 4) une var nommée nomsPaysEurope pour mettre tous les drapeaux d'Europe
this.nomsPaysEurope = ["FRANCE","ITALIE","LITUANIE","POLOGNE","UKRAINE"];
this.flagsOfEurope = ["france1","italie1","lituanie1","pologne1","ukraine1"];
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// 5) une var nommée nomsPaysOceanie pour mettre tous les drapeaux d'Océanie
this.nomsPaysOceanie = ["NOUVELLE ZÉLANDE","PAPOUASIE N. GUINÉE"];
this.flagsOfOceania = ["nouvelleZelande1","papouasieNouvelleGuinee1"]
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////
this.modal_mc.visible = false;
this.modal_mc.addEventListener('mousedown',modalF);
function modalF(){
// do nothing. prevent flags from being mousedowned.
// console.log('modal');
}
///////////////////////////////////////
/* Determine the width and height of the Stage, and preserve these values within variables to accces
across our interactive later on. The stage.canvas object
can be uses to access both width and heignt when writing JavaScript.
This is especially useful if we were to adjust the size of our Stage
dynamically based upon the parent webpage or some othor factor */
var stageHeight = stage.canvas.height;
var stageWidth = stage.canvas.width;
/* Pour aller à la page d'information du jeu. Using frame labels is much flexible,
it allows you to shift the frames around without having to update the specific frame
number in your code. You can also use commands such as gotoAndStop() and gotoAndPlay()
to effectively control the playhead */
this.btn_instructions.addEventListener("mousedown", allerInfo.bind(this));
function allerInfo() {
this.gotoAndStop("info");
}
this.btn_jouer1.addEventListener("mousedown", allerJouer1.bind(this));
function allerJouer1() {
this.gotoAndStop("cAfrique");
}
this.btn_jouer2.addEventListener("mousedown", allerJouer2.bind(this));
function allerJouer2() {
this.gotoAndStop("cAfrique");
}
//------------------- LES CODES EN 6 ÉTAPES ------------------------------------//
this.continentIndex = 0;
this.continentFlags = this[this.flags[this.continentIndex]];
this.continentNoms = this[this.nomsPays[this.continentIndex]];
this.flagClickF = function(e){
var i = e.currentTarget.ivar;
if (this.nomsDrapeaux_tf.btnLabel.text == this.continentNoms) {
this.correctAnswers++;
var correct = true;
this.next_mc.visible = true;
} else {
this.incorrectPerFlag++;
}
checkForEndF(correct,this);
}
function checkForEndF(correct,tl){
if(tl.incorrectPerFlag==tl.maxIncorrect){
tl.incorrectAnswers++;
tl.incorrectPerFlag = 0;
tl.next_mc.visible = true;
tl.modal_mc.visible = true;
tl.incorrect_tf.text = tl.incorrectAnswers;
tl[tl.continentFlags[tl.index]].visible = false
tl[tl.continentFlags[tl.index].split('1')[0]+22].visible = true;
}
if(correct){
tl.incorrectPerFlag = 0;
tl.modal_mc.visible = true;
tl.next_mc.visible = true;
tl.correct_tf.text = tl.correctAnswers;
tl[tl.continentFlags[tl.index]].visible = false
tl[tl.continentFlags[tl.index].split('1')[0]+22].visible = true;
}
}
this.next_mc.addEventListener('mousedown', nextF.bind(this));
function nextF() {
this.index++;
//console.log(this.index+" "+this.continentNoms[this.index])
this.next_mc.visible = false;
this.modal_mc.visible = false;
if (this.index == this.continentNoms.length) {
//if (this.index >0) { // for testing
var tl = this;
if(this.continentIndex == 4){
setTimeout(function(){ tl.gotoAndStop("final2"); tl.modal_mc.visible=false}, 3000);
} else {
//console.log(tl.currentFrame+10);
setTimeout(function(){ tl.gotoAndStop(tl.currentFrame+10); tl.modal_mc.visible=false}, 3000);
}
return;
}
this.nomsDrapeaux_tf.btnLabel.text = this.continentNoms[this.index];
if ((this.index == Math.floor(this.continentNoms.length/2) && (this.continentIndex == 1))) {
this.gotoAndStop("choix");
}
}