Hi! Here is a little fun demo using AS3. Although the code is big, I tried to keep it simple using the Animate CC timeline a lot. If you take a look at the FLA, you'll see it's kind easy to edit and extend. Code: Frame 1: import flash.display.MovieClip; import flash.display.SimpleButton; import flash.events.MouseEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.net.URLRequest; import flash.utils.setTimeout; var questionDelay:Number = 1000; var toWin:uint = 70; var totalQuestions:uint = 10; var score:uint = 0; var highscore:uint = 0; var questionChannel:SoundChannel = new SoundChannel(); var alternativeChannel:SoundChannel = new SoundChannel(); var bgmChannel:SoundChannel = new SoundChannel(); var sfxChannel:SoundChannel = new SoundChannel(); var questions:Object = { question0: {correct:2, points:10}, question1: {correct:0, points:30}, question2: {correct:0, points:20}, question3: {correct:3, points:50}, question4: {correct:1, points:10}, question5: {correct:3, points:20}, question6: {correct:2, points:20}, question7: {correct:3, points:20}, question8: {correct:1, points:10}, question9: {correct:1, points:50} } var audio:Object = { bgm: { start:"audios/bgm/Moonshine_Town.mp3", ingame:"audios/bgm/Bluebird.mp3", end:"audios/bgm/Sour_Tennessee_Red.mp3" }, sfx: { correct:"audios/sfx/335908__littlerainyseasons__correct.mp3", wrong:"audios/sfx/142608__autistic-lucario__error.mp3", button:"audios/sfx/264446__kickhat__open-button-1.mp3" } }; // start function start():void { score = 0; gotoAndStop("start"); listeners(); playSound(audio.bgm.start, "bgm", 0.2); if (highscoreText) highscoreText.text = "HIGHSCORE: " + highscore; } function startGame():void { score = 0; gotoAndStop("ingame"); enableQuestions(true); readQuestion(); playSound(audio.bgm.ingame, "bgm", 0.2); scoreText.text = "SCORE: 0"; } // ingame function changeQuestion(e:SimpleButton):void { var alternativeIndex:uint = uint(e.name.slice(11, e.name.length)); var current:uint = currentFrame - 3; var correct:uint = uint(questions["question" + current].correct); var points:uint = uint(questions["question" + current].points); var letter:MovieClip = this["letter" + alternativeIndex]; enableQuestions(false); if (alternativeIndex == correct) { letter.gotoAndStop("correct"); score += points; scoreText.text = "SCORE: " + String(score); playSound(audio.sfx.correct, "sfx"); } else { letter.gotoAndStop("wrong"); playSound(audio.sfx.wrong, "sfx"); } setTimeout(function():void { if (current < totalQuestions - 1) { nextFrame(); readQuestion(); enableQuestions(true); letter.gotoAndStop("normal"); } else { playSound(audio.bgm.end, "bgm", 0.2); if (score >= toWin) { gotoAndStop("win"); setWin(); } else { gotoAndStop("lose"); setLose(); } } }, questionDelay); } function readQuestion():void { playSound("audios/questions/question_" + (currentFrame - 3) + "/question.mp3", "question"); } function readAlternative(index:uint):void { playSound("audios/questions/question_" + (currentFrame - 3) + "/alternative_" + index + ".mp3", "alternative"); } // end function setWin():void { var percentage:Number = (score - toWin) / (totalPoints() - toWin); star0.visible = false; star1.visible = false; star2.visible = false; star3.visible = false; star4.visible = false; if (percentage < 0.2) stars(1); else if (percentage >= 0.2 && percentage < 0.4) stars(2); else if (percentage >= 0.4 && percentage < 0.6) stars(3); else if (percentage >= 0.6 && percentage < 0.8) stars(4); else if (percentage > 0.8) stars(5); if (highscore < score) { highscore = score; newRecord.visible = true; } else newRecord.visible = false; finalScoreText.text = String(score); listeners(); } function setLose():void { finalScoreText.text = String(score); listeners(); } function stars(index):void { for (var i = 0; i < index; i++) this["star" + i].visible = true; } function totalPoints():uint { var sum:uint = 0; for (var key:String in questions) sum += uint(questions[key].points); return sum; } // common function mouseHandler(e:MouseEvent):void { if (e.type == MouseEvent.MOUSE_DOWN) { if (e.currentTarget == startButton) { playSound(audio.sfx.button, "sfx"); startGame(); } else if (e.currentTarget == homeButton) start(); else if (e.currentTarget == restartButton) startGame(); else if (e.currentTarget.name.indexOf("alternative") == 0) changeQuestion(e.currentTarget as SimpleButton); } else if (e.type == MouseEvent.MOUSE_OVER) { if (e.currentTarget.name.indexOf("alternative") == 0) readAlternative(uint(e.currentTarget.name.slice(11, e.currentTarget.name.length))); } } function playSound(path:String, channelType:String, volume:Number = 1, start:Number = 0, loops:int = 0):void { var sound:Sound = new Sound(); var sTransform:SoundTransform = new SoundTransform(); sound.load(new URLRequest(path)); if (channelType == "bgm") { bgmChannel.stop(); bgmChannel = sound.play(start, loops); sTransform.volume = volume; bgmChannel.soundTransform = sTransform; } else if (channelType == "sfx") { sfxChannel.stop(); sfxChannel = sound.play(start, loops); sTransform.volume = volume; sfxChannel.soundTransform = sTransform; } else if (channelType == "question") { questionChannel.stop(); questionChannel = sound.play(start, loops); sTransform.volume = volume; questionChannel.soundTransform = sTransform; } else if (channelType == "alternative") { alternativeChannel.stop(); alternativeChannel = sound.play(start, loops); sTransform.volume = volume; alternativeChannel.soundTransform = sTransform; } } function enableQuestions(enable:Boolean):void { if (enable) { if (alternative0 && !alternative0.hasEventListener(MouseEvent.MOUSE_DOWN)) { setTimeout(function():void { alternative0.mouseEnabled = true; alternative1.mouseEnabled = true; alternative2.mouseEnabled = true; alternative3.mouseEnabled = true; alternative0.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative1.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative2.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative3.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative0.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative1.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative2.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative3.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler); }, questionDelay * 2); } } else { alternative0.mouseEnabled = false; alternative1.mouseEnabled = false; alternative2.mouseEnabled = false; alternative3.mouseEnabled = false; alternative0.removeEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative1.removeEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative2.removeEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative3.removeEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); alternative0.removeEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative1.removeEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative2.removeEventListener(MouseEvent.MOUSE_OVER, mouseHandler); alternative3.removeEventListener(MouseEvent.MOUSE_OVER, mouseHandler); } } function listeners():void { if (startButton && !startButton.hasEventListener(MouseEvent.MOUSE_DOWN)) startButton.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); if (homeButton && !homeButton.hasEventListener(MouseEvent.MOUSE_DOWN)) homeButton.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); if (restartButton && !restartButton.hasEventListener(MouseEvent.MOUSE_DOWN)) restartButton.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); } Frame2: stop(); start(); FLA download: animate_cc_as3_super_quiz_game.zip - Google Drive Preview: I hope it can help you. Regards, JC
... View more