Flash actionscript updating text on a different timeline dating for satisfaction
Once the user is done, the Flash movie goes to frame 2 where the answers are checked and the score is given.Since the quiz and the results are separated into two different frames, then the code will be separated as well.This will be especially useful if you had numerous items in your code that need to reference how long your array is.Imagine if you hard-coded the data numerous times in different parts of your code.And then we can just update that variable whenever needed.This is where our a Questions = "What is the biggest planet in our solar system?Of course we will have to be the ones to provide what the correct answers are, which is why this array is already populated with values.When the array was created, the values were also declared in the array constructor, therefore populating the array.
So we just create this array first, but we don't put any values in it initially.Then every time you decide to add or subtract items to the array, then you'll have to go back to all those hard-coded parts of your code, and manually change the value. So our updated event listener function will now look like this: , then it means that we don't have anymore questions and the quiz is done, and it can now move to frame 2 where the results will be displayed.So finally, our updated event listener function will look like this: In the next part of this tutorial, we will work on the code that will display the answers that the user submitted alongside the correct answers."; So now, if you test the movie, you should see the first question displayed in the Text Field.And now that we have that, the next thing we need to fix is how our Flash movie is going to respond whenever a quiz taker types an answer in the input field and clicks on the submit button. When the user clicks on the submit button, our flash movie should: array (the first value that is pushed to the array gets an index of 0, the next one after that will get an index of 1, and so on...).We will also work on the code that will check the answers and calculate and display the user's score.Here's the frame 1 code in full: stop(); var n QNumber: Number = 0; var a Questions: Array = new Array(); var a Correct Answers: Array = new Array("Jupiter", "Mars", "war", "Titan"); var a User Answers: Array = new Array(); a Questions = "What is the biggest planet in our solar system? This tutorial comes with an exercise file (the download link can be found at the top of the article).Let's go ahead and open it and take a look at its contents. The first frame contains the elements needed for the user to take the quiz."; a Questions = "Which planet in our solar system is the 4th planet from the sun?"; a Questions = "Mars is named after the Roman god of ___."; a Questions = "What is the name of Saturn's largest moon?