Quantunet.com

Flash QuickSkills

Variables  

What Is A Variable ?
Basic
A variable acts as a location to store data.

Intermediate


Advanced
A Class is a defined data type, an aggregate of named data elements and a set of operations to manipulate that data.

A class can contain primitive data types and referenced data types and a method by which to manipulate the data in these data types to create an new processed data type.

Declaring Variables?
variables must be declared before they can be used in a program. Declaring a variable creates the location in which to store data. That is a defined area of memory that is responsible for holding a piece of data.


var height;

Assigning A Value
Once the variable is declared it can then be assigned a value. Initially the variable only contains random data and so must be given a specific data value as defined by he user.

height = 10;

The variable has now been defined (storage location created) and value assignmenta to it (data put in the storage location). It can now be called upon in a program so that the data within it can be used when needed by the program.

Data Types
To use a custom class you need to define a class head and class body and save the class in an seperate actionscript file .as
Each class must have its own .as file and be stored in the same directory as the main document files.

The class head assign Value To A Variable


Local Variables
Global Variables


var height; //declares global variables
var width;

height = 10; //defines variable values
width = 20;

// variables are used to define the behavior of a custom function

function ntriangleArea(): number{
var area = 0.5*height*width; //declares local variable
return area;
}

// function is called, result is returned and then written to the output window

trace(ntriangleArea());
Note: Conventionally class names begin with a capital letter.


© 2005 - 2007 Quantunet.com All Rights Reserved
Home | Terms of Use | Contact Us