Skip Navigation.

Flash: Programming Tutorial: Faucet

For this part of the tutorial, we'll be making a faucet just like the one from the earlier programming pages, which is shown below.

From the earlier programming pages, we have some of the ActionScript to increase the water flow, but we don't have the complete program. This brief tutorial page covers making that program, and then you'll be ready for the next tutorial that covers more ActionScript.

To make this code work for your faucet overall, you have to have two buttons to make up the handle - one increases the water flow and the other decreases it. To make this program, you would make the two buttons and the faucet, putting all of them on the same scene of your movie.

This faucet uses the code:

on (release) {
  if (flow < 3) {
  gotoAndPlay (10);
  }
}  

We'll make one image of the faucet and then two buttons - one for each side of the knob. The first button we'll work on will have the code above. To make this work, put the faucet and the two buttons in Scene 1, Frame 1. Add another layer, which will be the actions layer. In the first frame of the actions layer, put a "stop" action.

Here's the .fla file for reference.

Back