Variables are important building blocks in the creation of applications. Variables are words/ containers that hold or represent data.

Variables
– Hold or represent data
Hold different types of data

Actionscript

var myName : String;
myName =  “Kev”;
trace (myName);

From the code above var will turn blue, when a word turns blue in Flash; these are keywords reserve by Flash for actionscript. The next step is to give this variable a name. In the code example above it is called myName. When it comes to naming variables there are certain rules that must be followed.

Rules for naming
– Cannot start with a number
– No spaces
– No special character

I have named my variable myName instead of myname or Myname because myName makes it easier to read.

The next step is to tell Flash the type of data this variable is going to be
Some Variables data types:
– Boolean
– int
– Null
– Number
– String
– uint
– void

We will be going into more details in later tutorials on the different types of variables. Now i will be putting in a text data, the way to do it is to type a (colon : ). In actionscript text data is known as String.

The next line of code (myName = “Kev”), i am actually giving a value to the myName variable. Text value or String are identify by being in quotes. You will notice that whatever is in quotes will be in green which is the default colour in Flash.

The last line of code actually tells Flash to display myName in the output window. Trace statements are extremely useful in debugging a program.

I will now show you another way to achieve a similar output. Instead of assigning the value of my variable in another line of code i can actually do it together when i am declaring the data type of the variable.

Actionscript

var myName : String = “Kev”;
trace (myName);

Feel free to post any questions should you have any.

2 Responses so far.


  1. Dweezil
    August 26, 2011, 1:57 pm

    Umm, are you really just giving this info out for nohtnig?


  2. Kev
    August 26, 2011, 6:28 pm

    Yes Dweezil, we are really giving out this info for free, apart from that we are creating a separate website to enhance the learning of actionscript 3.0. Stay tune for more info. Cheers

Write down your thoughts

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>