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);
}
textName=name[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.
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: 8 Votes: 38 |
| » Author |
| No details available. |
| » Download |
| Download the files used in this tutorial. |
| Download (15 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!