First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Simon Bolus | Website: http://www.graphicinjection.co.uk

Constructing the Back and Forward Buttons (1)

The back and forward buttons need to appear inactive when they are inactive we do this by putting them in frame 2 of there own movie clip instances, a dummy button graphic is put in frame 1, these movie clips are controlled by logic movie clips on the main stage which scan the arrays to see if they are empty or not (By logic movie clip I mean a movie clip consisting of just script which in this case will continuously loop (scans)).

Here's how it is done:

Select the back button and press F8 to make into a symbol call it "backButton" and select movie clip edit the movie clip as follows:

Put a "stop ();" command in frame 1 and the add a new key frame in frame 2 (not a blank key frame). go back to frame 1 and select the button instance, press "Ctrl+ B" or "modify>break apart" from the menu - this creates a graphical "dummy button". Go back to frame 2 and add this script to the button:

on (release) {
	_root.forward.push( _root._currentFrame);
	frameNowOn = _root.back.pop();
	backFrame = _root.back.pop();
	_root.gotoAndPlay (backFrame);
	}
}

OK, the _rootforward.push( _root._currentFrame); adds the present frame number to the forward array for use by the forward button.

The frameNowOn = _root.back.pop (); deletes the frame number from the back array which we are now on, we need to do this so we have the previous frame number showing at the end of the back array not the one we are now on, this is so that the backFrame = _root.back.pop (); line can set the variable backframe to the previous frame number the play head was on.

The _root.gotoAndPlay (backFrame); tells the play head on the main timeline to go to the backFrame variable value.

Now drag an instance of the backButton movie onto the stage name the instance "backButton".


For the forward button movie clip - do the same as we did for back button but call the movie clip fowardButton and name the instance "forwardButton" and put the following code on the button:

on (release) {
    forwardFrame = _root.forward.pop();
    _root.gotoAndPlay(forwardFrame);
}

Similar kind of thing to the back button code but we don't need to delete the last value in the array because this is the number we want to jump to.

» Level Advanced

Added: 2001-03-14
Rating: 6.75 Votes: 64
(10 being the highest)
» Author
No details available.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • 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.