Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Interactivity/Other

Categories Interactive Background
Author: Clinton Montague

 
Page 4
«prev 1 2 3 4 5 next»

The Previous Background Button

Open up the actions panel for the button that you want to change the background to the previous one. It is sensible to use a button on the left to do this but it does not matter. In the actions panel, type in the following script (again, Expert Mode is probably best.)

on (release) {
 a -= 1;
 if(a == 0) {
 a = 4;
 _root.Back.gotoAndPlay ("BG" add a);
 }
 else {
 _root.Back.gotoAndPlay ("BG" add a);
 }
textName=name[a]
}

This script might look horrible but it is actually quite simple if you look at it one step at a time.

  • The on (release) tells Flash to do the instructions that follow when the user releases the mouse button.


  • The a -= 1 is a short and lazy way of writing a = a - 1, they both mean the same thing. If a was 3 for example, Flash would take 1 away from 3, and end up with 2 (3 -= 1 or 3 = 3 - 1 both equal 2).


  • The next bit checks to see IF a is zero, there is no background for zero so a is reset back to 4. I'll tell you what the next bit means in a minute.


  • Incase a is not equal to zero (which it probably will be in most cases), you have to tell Flash to do something else. The variable a does not need to be reset this time becuase there will always be a background for that number. a will never be greater than 4 becuase it is reset to 4, and never less than zero because it is reset when it gets to zero.


  • Now for the nasty looking bit _root.Back.gotoAndPlay. Remeber that when you dragged the background MC from the library to the main stage, you gave it an instance name of Back? this is why. That name enables Flash to find it and do something with it, in this case gotoAndPlay. _root means the root (or highest) level, the . tells Flash that the next bit belongs to that level (the instance name Back is on the top level) and the second . means a property of the Back instace (this one tells Flash to goto and play the bit in the brackets).


  • What Flash has to goto and play is "BG" add a. The labels in the background MC were BG1, BG2, BG3 and BG4, remeber? Well this actionscript tells Flash to go to BG then the add a tells Flash to stuff whatever is stored in the variable a onto the end. The fancy name for this is Concatenating, but don't worry about that. If the number stored in a was 2, then Flash would end up with the line gotoAndPlay ("BG" add 2) which would be gotoAndPlay ("BG2").


  • The last line textName=name[a] does exactly the same as the array in the Variables layer. It does nothing different, it only refreshes it, like a web browser.

«prev 1 2 3 4 5 next»

» Level Intermediate

Added: : 2001-03-14
Rating: 7.78 Votes: 38
Hits: 10525
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (15 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments