|
|
Search Tutorials
Part 1 - Setting up the Main Flash Moviea) Setting up the main movie frame actionsAdd 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 screenFirst 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. 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.
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|