Flash Menus: Buttons

Home • Members Tutorials Forum iSnapChat Contact Us 

 


Flash Tutorials

   

Flash - Sliding Menus
Moving an Object on Roll Over using ActionScript

Flash MX Flash 8 Flash CS3 Flash 5

 

Free Flash Tutorial


Step 7     <<   Previous      Intro   1   2   3   4   5   6   7   •   >>      

 

Step Seven: Placing a Button on Stage

  1. The last stage is to place a button on stage and set the ActionScript so that the movie clip moves when you roll over or click the button.  You will need to either create a new button and place it on stage or drag a button out of the common button library.  Either make your own button or go to Window > Other Panels > Common Libraries > Buttons and drag a button onto the main stage. 
  2. Select the button and open the ActionScript panel. Insert the following code:

    on (rollOver) {
       yTargetMC = 50;
    }

Change the target number to a number that suits the position that you want the movie clip to stop at.


Note: The target number must be different to the number in frame 1 otherwise the movie will not move.

Note: As an alternative make the movie clip move on click:


on
(release) {
   yTargetMC = 50;
}

Finished 


Your first movie clip should now be sliding happily to the position that you want it.  You may wish to add additional buttons each of these should have the same ActionScript as Step 7 but a different target destination number. Then you may move your movie clips on and off stage.


You may also wish to add additional movie clips so that one button moves more than one object.  There is an example below.  The instance name needs to be different and all references in the script will need to be changed to reflect this. Download the example below to see the additions.



My Example: Download the Flash file  Int 101b



A Final note: X & Y


If you want your movie to move from left to right as opposed to up and down just change all the Y's to X's.  With a little fiddling around you should also be able to move things on diagonals. To do this you will have to have a script for both the X and Y axis.


Have fun!

 

Please indicate what you thought of this tutorial 
10 is the best: 
10 9 8 7 6 5 4 3 2 1

         

Step 7     <<   Previous      Intro   1   2   3   4   5   6   7   •   >>      


Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.