Flash Education: Attaching Actionscript

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Tutorial: Creating Links within a Flash Movie


Free Flash Tutorial


Step 7    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10   11     Next   >>       >>   Webwasp Mates

 

Step Seven: Attaching Actionscript to the First Button - Frame 1 Next

Now it is time to make the Buttons work. This is also done with ActionScript.

  1. In the Timeline, if you are not already on Frame 1, click on: Frame 1
  2. Note: When you click on the Keyframe (black dot) you will find that all the objects in that Frame are selected. In this case the objects are the text and the button. You know that objects are selected by the blue rectangles:



    When attaching ActionScript to buttons it is important that only the button is selected otherwise the actions may get attached to the wrong object. Thus the first step is to de-select all the objects.

  3. Click off Stage so that all the objects are: De-Selected (Ctrl Shift A)

  4. All the objects are now de-selected.

  5. On the stage click on the: Button

  6. Only the Button is selected.

  7. Open the Actions Panel: Window > Actions (F9)
  8. Important: If you have selected the button correctly the Actions Panel should say Actions - Button in the top left corner. In my experience beginners often make the error of attaching their ActionScript to the wrong object. Get into the habit of checking what the Actions Panel says in the top left corner:


    Always Check what it says in the top left corner of the Actions Panel before applying Actions.

    Note: Script Assist should still be ticked:    >  

  9. Click on the: Plus Sign > Global Functions > Timeline Control > Goto (Esc G O)

    You will see the following ActionScript:

     on (release) {
            gotoAndPlay(1);
        }

    This means that when the mouse button is released you will go to and Play Frame 1. You will need to make an adjustment so that the button takes you to Frame 2 and Stops.

  10. For Frame type the number: 2

  11. The Button will now take you to Frame two and will Play.

    Now you need to make sure the Movie does not animate by changing the Play to a Stop.

    If you were to test the Movie this is what would happen:


    Press the Button to test.

    You will see that when pressed the Movie animates and returns all the way back to Frame 1 and stops.

    Play means to animate so we need to get rid of the Play and replace it with a Stop.

  12. In the Actions Panel select the Radio Button:

  13. This means that when the mouse button is released you will go to Frame 2 and Stop. Which is what is needed!

  14. Close the Actions Panel by clicking on the cross: (F9)

  15. Time to test again. Go to: Control > Test Movie (Ctrl Enter)

  16. Click on your button. You should move to Frame 2 and Stop.

    The buttons in Frame 2 will not work yet as you have yet to set the ActionScript for these.

  17. Close the Test Window by clicking on the cross:

  18. Save your file: File > Save (Ctrl S)

         

Step 7    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10   11     Next   >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates

46569 visitors to this page since June 06

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates 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.