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 |
» Author |
No details available. |
» Download |
Download the files used in this tutorial. |
Download (18 kb) |
» Forums |
More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.
Comments
There are no comments yet. Be the first to comment!