Flash Game Design  
 
   
 
Tutorials Articles
   
       
 
 
Full Flash Website  
Making the Buttons Move
Step 47.
In the previous section we made the buttons functional, so when theyre pressed, the section changes. Now we're going to make the buttons slide up when they've been pressed, to make the a little more interesting. This will be done in the same frame as the previous section, but we'll be adding onto the existing code.

Line 1 - The code from the previous section, to tell the content Mc to go to the label of 1st page of the site - "home"

Line 2 - A variable called current s created, which will hold the name of the button when it's pressed.

Line 3 - A boolean variable is created which we will use to see if the buttons needs to be moved.

Line 4 - Each button's Y position will be at 0, but when it's pressed it's going to slide up to position - 10. This value is held in "yMove".

 
Step 48.

Line 5 - The onPress function from the previous part.

Line 6 - An IF statement is created to check to see if the variable "current" is holding the name of the "this" (home_button). If it is, that mean the button is already at a Y position of -10, so we don't need to do anything.

Line 7 - If the variable "current" is holding the name of the "this" (home_button), we set current's Y position to 0. So if, for example, "current" was holding "media_button" and the home button is pressed, the "media_button" would move to a Y position of 0.

Line 8 - setMove is set to true, so we know that we can start moving the button (more will be explained further below)

Line 9 - the content MC is told to go to the label "home"

Line 10 - Since a new button has been pressed, current needs to be set to "this" (home_button)

 
Step 49.
Line 13 - 44 - Each button is given the same functionality, but with a different label to go to.
 
Step 50.

Line 45 - an onEnterFrame function is created, which repeatedly executes the code between the braces {}

Line 46 - Now remember with each button onPress, we are setting "setMove = true"? With the onEnterFrame function we repeatedly check to see if this has happened, so we know when to move it up to -10 Y position.

Line 48 - Now remember with each button onPress, we are setting "setMove = true"? With the onEnterFrame function we repeatedly check to see if this has happened, so we know when to move it up to -10 Y position.

Line 49 - If setMove has been set to true, we now need to check if the button has reach a Y position of -10. If it hasn't we decrease the button (current) by 1 pixel repeatedly(--), until it's reached -10.

Line 50 -52 - When the button has reached -10, we change "setMove" to false, because we no longer need to move it.

So now that the buttons have now been given some basic functionality, go to the final part: Full Flash Site - Creating the Drawing in Sequence
Part: 1 | 2 | 3 | 4 | 5 | 6 | 7
 
   
 
   
 
Site Copyright © 2006 - 2009 Nick DS. All rights reserved.