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 />

Notice here that the ‘tabIndex’ is set for each of the input box text fields and the focus is set<br />

<strong>to</strong> ‘name’.<br />

The functionality for the form is basically handled by <strong>Flash</strong>. A text field input box allows for<br />

keyboard input, character deletion, copying and pasting without a single line of code. The place<br />

where some <strong>ActionScript</strong> is required is for the ‘register’ but<strong>to</strong>n. This has a simple ‘on (release)’<br />

method.<br />

1 //Register but<strong>to</strong>n action<br />

2 on (release) {<br />

3 if (emailcheck(email) && name!="" && password!="") {<br />

4 loadVariables("scripts/register.asp","","POST");<br />

5 nextFrame();<br />

6 } else {<br />

7 warning.go<strong>to</strong>AndPlay(2);<br />

8 }<br />

9 }<br />

Listing 21.2<br />

First we make a check for a legitimate email using a function call; assuming this is OK we then<br />

check for a name and password entry. If everything is in order, then we can send all the variables<br />

in the current <strong>Flash</strong> movie <strong>to</strong> an ASP page, using the POST action, and then move <strong>to</strong> the next<br />

frame. If the data entered is invalid, however, then we display a warning message that is embedded<br />

in the movie clip ‘warning’.<br />

The ‘emailcheck’ function works by testing for the presence of both the ‘@’ symbol and a dot<br />

character, ultimately returning true only if they are both present in the email string passed <strong>to</strong> the<br />

function.<br />

1 function emailcheck (str) {<br />

2 at = false;<br />

3 dot = false;<br />

4 for (i=0; i

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

Saved successfully!

Ooh no, something went wrong!