Saturday, March 17, 2007

Using XML with Flash

In our project, we have decided to have a quiz which help users check their improvement in learning. However, the problem is if we make a flash with each frame for one question; it will be very cumbersome and difficult to change. A possible solution for this is to have an external file with questions and the Flash is going to load this file when it is executed. Therefore, to change or add new questions to the Flash, we only have to change the external file.

The external file should be written in the XML because this markup language is easy to understand by both human and computer software. This is the sample structure of the question file.

quiz.xml


In this example, there will be 1 question in the file (num="1"). The structure of this question are an URL to the picture of a hiragana character (hiragana/sa.png), a correct pronunciation for this character (sa) and 3 wrong other answers.

After having this XML file, the Flash will read it to get questions, suffle their order and display them to users. This is the example for this Flash. It shows users 5 questions in a random order and users can only answer each question once. After they finish 5 questions, the Flash will show the result: how many correct and wrong answers.

As I just focused on the coding part, this Flash's interface is not so interesting. However, this is its screenshots.





No comments: