Search Tutorials
Constructing the Back and Forward Buttons (2)For the back button logic: Create a new movie clip call it backLogic - add 2 key frames in the time line, in the first key frame put the code: if (_root.back.length>1) {
_root.backButton.gotoAndStop(2);
} else {
_root.backButton.gotoAndStop(1);
}
This checks to see if the length of the array has more than one value (more than one value is needed to make the back button necessary , i.e. we don't need it to go back to the frame we are already on) If this is true the code instructs the backButton movie clip instance to goto and stop on frame 2 of its time line which is where the back button sits. If the statement is false the code instructs the movieclip to goto and stop on frame 1 Now put this in the second key frame: gotoAndPlay (1); This loops the movie clip so it will keep on checking. Now drag an instance of this logic movie clip on to the main stage put it next to the back button. The forward button logic is slightly different: Do the same as above but call it forwardLogic and put this code in the first key frame: if (_root.forward.length>=1) {
_root.forwardButton.gotoAndStop(2);
} else {
_root.forwardButton.gotoAndStop(1);
}
The only difference this has to the back button is that it checks to see if there are any values in the forward array i.e. 1 or more (>=1). Don't forget the gotoAndPlay (1) in frame 2, now drag an instance of this logic movie clip on to the stage put it next to the forward button. That's it test your movie and your away, any problems go back and check the code or cross reference it with my movie in the download. You could also try using flash's debugger in test movie to check if the variables and arrays are working properly Hope this tutorial was useful, have fun!!!!!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|