
-----------------------------------
Delta
Thu Feb 05, 2004 2:27 pm

[Tutorial] ActionScript - Variables
-----------------------------------
This tutorial is one of many of my tutorials for Flash MX - Actionscript. In 
this tutorial you will learn how to declare and use variables with 
actionscript.

Declaring variables in actionscript is very similar to most languages.
var number = 15;
var word = "text";
var answer = "true";
var num2 = "0.3423";

String : A string is a sequence of characters such as letters, numbers,
            and punctuation marks. You enter strings in an ActionScript 
            statement by enclosing them in single or double quotation marks.


var firstName = "Ron";
var lastName = "Zimmer";

             You can use the addition (+) operator to concatenate, or  
             join, two strings.


var fullName ;
fullName = firstName + " " + lastName;

              Some characters can't be displayed as a literal part of a string 
              without  being preceded by a backslash (\). This is called
              "escaping" a character.	 There are other characters that can't be 
              displayed in ActionScript except by special escape sequences.  
              The following are some examples :
		 
              \b - Backspace character (ASCII 8)
              \f  - Form-feed character (ASCII 12)
              \n - Line-feed character (ASCII 10)
              \r - Carriage return character (ASCII 13)
              \t - Tab character (ASCII 9)
              " - Double quotation mark
              \' - Single quotation mark
              \\ - Backslash
 

Boolean : A Boolean value is one that is either true or false. ActionScript 
               also converts the values true and false to 1 and 0 when  
               appropriate.

var rUHuman = true;
var rUABird = false;


Numbers : A number value can be a negative or positive integer or real 
                number (decimal numbers). Simple mathematic functions such 
                as addition can be used as followed.

var number = 2 + 6;

	Actionscript automatically refers to BEDMAS (Brackets, 
                Exponents, Division, Multiplication, Addition, Subtraction) if 
                your not careful placing your brackets then your answer could 
                be flawed. Example :

var number = 6*7+4-2;

                Above your answer would be 44.

var number = 6*(7+4-2);

	Above your answer would be 54.
        
                Number values can be held in variables and worked thru them 
                example :

var num1 = 7;
var num2 = 8
var total = num1 + num2;

		  
                  Operators : 
		 
                  + Addition
 
                  * Multiplication
 
                  / Division
 
                  % Modulo (remainder of division)
 
                   - Subtraction
 
                  ++ Increment
 
                   -- Decrement
 
                  In the following example, age is incremented first and then
	  tested against the number 30: 

if (++age >= 30)

                   In the following example, age is incremented after the test
	    is performed: 

if (age++ >= 30)


                   If a variable is given a name but no value the default value given to it is undefined.


That concludes the tutorial on variables if you are confused with anything don't be afraid to ask ;)
