Action Scripting 3.0

Alejandra Jarabo
MAT 116

Media Arts & Technologies. Santa Barbara City College
PROGRAMING CONCEPTS

VARIABLES

A Variable is a container/envelope/ box that holds data (It's a place were you can hold information)

That held information can be changed later (through the code).

A variable is represented by a name.

   

Variables most often hold one of 3 types of information (it is called data type),

VARIABLE DATA TYPE (Notice that data types are always written capitalized)

• Number (the variable holds a numeric value)
• String (the variable stores words or pieces of text)
• Boolean (the variable stores a true/false statement)

 
   
HOW TO DECLARE A VARIABLE  


The first time you introduce a variable in your code, you need to DECLARE the new variable, including word var, the name of the variable, the data type and initial value.

The name of the variable should be one word, easy to remember or identify, lowercase, no special characters.

REMEMBER to end every line of code with a semicolon (;)

var score: Number=0;
var moneyinbank: Number= 300;
var girlfriends: String= "Kelly, Ashley, Carrey";
var hadbreakfast: Boolean = True;

var
name of variable : data type = initial value ;
var
score : Number = 0 ;
var
moneyinbank : Number = 300 ;
var
girlfriends : String = "Kelly, Ashley, Carrey" ;
var
hadbreakfast : Boolean = True ;

 

 
   
HOW TO CHANGE THE VALUE OF A VARIABLE


After the variable has been declared in the code, you can refer to it by just naming it and changing the value.

score= (score +1);
moneyinbank= 500 ;
girlfriends=(girlfriends + "Anna");

To check the current value of a variable or simply check if it´s working, you can use the function trace

trace()

Place the name of your variable inside the parenthesis.
If I already have declared a variable called score,

trace(score);


Then test the movie and look at the OUPUT WINDOW; the value of your value will show there.