First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Part 1 - Setting up the Main Flash Movie

a) Setting up the main movie frame actions

Add the following ActionScript to the 1st frame of the movie:

NumLow = 0;
NumHigh = 10;
loadVariablesNum ("GuestBook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);

The first 2 lines set the lower and upper limit of guest book entries to display to their default values of 0 and 10.  The next line loads the initial Guest book entries (1-10).  These appear when you first open the Guest Book.  In this example we are just attaching the needed variables onto the end of the string, you can just as easily remove everything after the ? in the loadVariablesNum function above and use the 'POST' option.  For some reason it's an old habit of mine to do it this way when *-testing.  You can change the number of entries that appear by changing the values for NumLow and NumHigh.  NumLow is the lower limit, NumHigh is the upper limit.  For example, if you want to display 20 entries at a time instead of 10 you can change the value of NumHigh to 20. 

b) Setting up the main load screen

First we are going to set up the area where the Guest book entries appear on the screen, along with the 'next' and 'previous' buttons.  The basic layout is shown to the right.  (You can probably skip this first part by looking at the included Fla file for examples).

Create a text field named 'Guest Book' as shown in the photo.  Make sure to make this a multiline dynamic text box field.  Also make sure to check off the HTML and Word wrap checkbox.  Enter some default text into this text area - (for example - Loading...).  The default text will be replaced as soon as the Guest book entries are loaded.

Create two additional text boxes named 'NumLow' and 'NumHigh', these will be used to tell the user what set of Guest book entries they are currently viewing.  Do not check the 'HTML' checkbox off for this one.

Create one last text field called 'TotalEntires' - this is used to show the user how many entries you currently have in your Guest book.

Create a Previous 10 and Next 10 button.

The following ActionScript is located on the Previous 10 button:

on (release) {
	if (NumLow == "0") {
	Guest Book = "No more before 0";
	else {
         NumLow = Number(NumLow) - Number(10);
	NumHigh = Number(NumHigh) - Number(10);
	Guest Book = "Loading Comments Numbered "+NumLow+" to "+NumHigh+" Please Hold";
	loadVariablesNum ("GuestBook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);

The first if statement in the above ActionScript is their so that users can not view entries before 0, which would cause an error.  If they try to press the previous button while they are viewing entries 0-10 they will see the error message 'No more entries before 0'.  The else part is used in most cases.  What this does is subtract 10 from both the 'NumLow' and 'NumHigh' variables.  The text in the 'Guest Book' text field is changed to 'Loading Comments numbered NumLow to NumHigh' with the next line.  Finally we call the script that we are using to display the results we are looking for.

The following ActionScript is located on the Next 10 button:

on (release) {
	NumLow = Number(NumLow)+Number(10);
	NumHigh = Number(NumHigh)+Number(10);
	Guest Book = "Loading Comments Numbered "+NumLow+" to "+NumHigh+" Please Hold";
	loadVariablesNum ("GuestBook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);

This is basically the same as the ActionScript for the Previous button except instead of subtracting 10 from the variables 'NumLow' and 'NumHigh' we are adding 10 to them.  The script will return a result if the user tries to view more entries then their are. This will be shown later.

The scrolling text box is probably the most difficult to explain.  Because this tutorial does not deal with scrolling text boxes I am not going to explain it here.  Their is however a great tutorial on this at flashkit.  For now you can just use the scrolling text box that is set up in the Fla that comes with the download.

» Level Advanced

Added: 2001-12-21
Rating: 8.92 Votes: 200
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content and applications. Specialty's include SQL, PHP, Perl, and XML.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.