hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
  Tree menu  Flex 2 Guestbook  Videobox  Simple mp3 player  Videoroom  Moving menu  Flash db board reader  Simple photo gallery  Simplecart and External Interface  Email in Flash II  Photo and Video gallery  New Store  Flash GuestBook V2  Flash-db Miniboard  ActionScript dictionary  Private chat with FlashCom  Flash Whois  An online store  Flash RSS reader  Net Tools - Whois in Flash  Flash Message Board  Flash GuestBook  Email in Flash  Sending Custom Ecards  Simple Live Counter with PHP
    Articles
Current Page (2) << Previous Page | Next Page >>  View Article Example >> 1 | 2 | 3 | 4 | 5 | 6

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);
stop();

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.

Current Page (2) << Previous Page | Next Page >> 1 | 2 | 3 | 4 | 5 | 6