Boolean values: True or False

A Boolean property or variable is one that can have only two possible values: true and false. It cannot have any other values.

One property of a movie clip that is Boolean is the visible property. In this movie we change the visible property of the car each time we click the button. Get Adobe Flash playerDownload the flash file

The code is shown below:

btnShow.addEventListener(MouseEvent.CLICK,showCar);
function showCar(e:MouseEvent):void {
	car.visible=!car.visible;  // ! means not: Make the visible property the opposite of what it is now
}

Notice the exclamation point. In ActionScript ! means not. The statement car.visible=!car.visible; means to make the visibility the opposite of its current value.

Another Boolean property for movie clips is the buttonMode. The statement below will make the cursor change to a hand when you move over the car. Usually you only set buttonMode to true when something will happen when you click the movie clip.

car.buttonMode=true;
Get Adobe Flash player
Download the flash file
Click the car to flip it around. The code for this movie is shown below. To make a Boolean variable the opposite use the exclamation point.
To make a numeric value the opposite multiply it by -1.
car.buttonMode=true;
car.addEventListener(MouseEvent.CLICK,flipCar);

btnShow.addEventListener(MouseEvent.CLICK,showCar);
function showCar(e:MouseEvent):void {
	car.visible=!car.visible;  // ! means not: Make the visible property the opposite of what it is now
}
function flipCar(e:MouseEvent):void {
	car.scaleX=-1*car.scaleX;  // flip the car on the X axis
}

NEXT: Moving Ball: Using if