First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Clinton Montague

The Next Background Button

Open up the actions panel up for the button that you want to change the background to the next one. It is sensible to put this one on the right hand side, but it does not matter. Type in the following script.

on (release) {
   a += 1;
      if(a == 5) {
         a = 1;
         _root.Back.gotoAndPlay ("BG" add a);
      else {
         _root.Back.gotoAndPlay ("BG" add a);

You might now be able to see how this script works without me explaining it now because it is very similar to the previous background actionscript. I won't explain it all this time, just a few key points that have changed.

  • The a += 1 does the opposite of a -= 1. It adds one onto a instead of taking one away. It is the same as a = a + 1.

  • This time, the IF checks to see whether a is 5, there is no background for 5 so you have to reset a back to 1.

The rest of the actionscript does exactly the same, so if you don't fully understand it, you should look back over it.

Thats it! You should now have a Flash movie that changes the background whenever the user clicks a button to change it. Click on Control >> Test Movie (CTRL and ENTER / CMD and RETURN) to try it out.

My finished movie is shown below I also added an extra text box to tell you what the value of the variable a is so that you can see what is happening inside the movie.

» Level Intermediate

Added: 2001-03-14
Rating: 7.82 Votes: 39
(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!


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