02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14 Quizzes<br />

Quizzes are a very popular form of entertainment on TV. In the UK, a quiz show called Who<br />

Wants To Be a Millionaire? rapidly became one of the highest rated programmes on TV. Quizzes<br />

are very simple <strong>to</strong> create, <strong>Flash</strong> <strong>MX</strong> <strong>2004</strong> even includes a template for creating them, but they are<br />

fairly demanding <strong>to</strong> maintain. In this chapter we will look at creating a database of questions using<br />

an SQL Server database. Because the questions are categorized by difficulty and <strong>to</strong>pic we can use<br />

this database <strong>to</strong> access questions in a variety of ways. The chapter builds on some of the concepts<br />

presented in Chapter 12.<br />

Multiple choice or free text?<br />

The easiest way <strong>to</strong> write a quiz program is <strong>to</strong> use questions that have multiple-choice answers.<br />

The advantage of using multiple choice is that any answer the user gives is either definitely wrong<br />

or definitely right. There is no ambiguity. Computer programs hate ambiguity. The disadvantage<br />

is that the quiz compilers are required <strong>to</strong> create the alternative ‘wrong’ answers, which adds <strong>to</strong><br />

their work. Free-text input is prone <strong>to</strong> errors. A quiz that allows free-text input for the answers<br />

must have answers that are very easy <strong>to</strong> input. Numeric answers are the least prone <strong>to</strong> error, but<br />

even here there are possible problems; if the answer is ‘3’, how do you respond <strong>to</strong> an answer<br />

of ‘three’? Both answers are correct but if the code is checking for ‘3’ and finds ‘three’ then the<br />

player could easily be marked wrong. Free-text input is very demanding <strong>to</strong> code; many answers<br />

that are incorrectly spelt must be marked as correct. But how do you allow for that? One way<br />

is <strong>to</strong> compare the player’s answer with the correct answer using a table of permissible, wrongly<br />

spelt answers. But however you approach it, the problem is complex and can result in ‘obvious’<br />

wrong answers being marked correct and vice versa. In this chapter we are, therefore, only going<br />

<strong>to</strong> consider the multiple-choice option. In the database of quiz questions we will keep the correct<br />

answer and three incorrect ones for each question.<br />

Creating a database<br />

Databases come in many shapes and forms. In this chapter we will concentrate on using SQL<br />

Server. This is a relational database management system for Windows NT servers. If you intend<br />

<strong>to</strong> do much work using SQL Server then you will need <strong>to</strong> get a copy of the developer edition.<br />

Unfortunately this costs about the same as a copy of <strong>Flash</strong> although a trial evaluation version is<br />

available. A simpler alternative is <strong>to</strong> use an Access-based database. Access comes with a complete<br />

version of Microsoft Office, and much of the material in this chapter applies <strong>to</strong> both databases.<br />

The major difference between the two options is in the way the server implements the database<br />

205

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!