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.

Chapter 21: High score tables<br />

Assuming the player is successfully logged in via either an existing cookie, the login page or<br />

registration then the page is set <strong>to</strong> ‘highscores.html’ which contains the swf from the project<br />

‘Examples\Chapter21\highscores.fla’. When this loads it shows a menu screen from which you<br />

can select one of three games, ‘Car Chase’, ‘Cat Splatt’ on ‘Ninga Rhino’. This screen also contains<br />

two but<strong>to</strong>ns, ‘Set Score’ and ‘View Scores’. The message displayed also shows the user’s name<br />

because this is known by the time the screen is displayed.<br />

The action for the ‘Set Score’ but<strong>to</strong>n first works out which game is selected by getting the state<br />

of the three radio but<strong>to</strong>ns. Only one but<strong>to</strong>n in a radio but<strong>to</strong>n group can be active. This value is<br />

used <strong>to</strong> choose the name of the game from an array of game names. The score is arbitrarily set <strong>to</strong><br />

a random value between 0 and 9999, then this data is sent <strong>to</strong> the ASP page ‘setscore’ via a query<br />

string. The playback head is set <strong>to</strong> the ‘wait’ frame, where playback loops until either ‘setscore’ or<br />

‘viewscores’ is set <strong>to</strong> ‘true’.<br />

1 on (release){<br />

2 var i, game=0, score;<br />

3<br />

4 for (i=1; i

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

Saved successfully!

Ooh no, something went wrong!