Posts

Showing posts from March 13, 2018

Adding the questions section

Image
Taking these questions from a year 7 revision site, I made my questions section of the game. For each scene, I used this code. However I had to alter it slightly each time so that I would not have any errors with repeating names or running two functions with the same name every time. Code stop(); var CorrectAnswer:Number=3; var Count:Number=1; Submit_btn.addEventListener(MouseEvent.CLICK, onClick); function onClick(event:MouseEvent):void{ var InputtedAnswer:Number = Number(Answer_txt.text); if (Count==3){ gotoAndPlay("Scene 23") } if (InputtedAnswer == CorrectAnswer){ gotoAndPlay("Scene 14") } else { MessageResult_txt.text = " Incorrect, Try Again"; Count++ } } Code Explained The variable 'CorrectAnswer' is assigned to the correct answer to the question The variable 'Count' is assigned to one When the submit button with the instance name submit_btn is clicked it activates th