Show Navigation || Hide Navigation
Variables
Information has to be stored somewhere if it's to be used later. In Actionscript 3.0 information is stored in containers called variables. For example you might need to store a list of usernames and passwords for your application and with use of variables this makes it all possible. Below is an example of simple a variable that contains a string of characters that contain the words Flash Essential.
- When you create a variable in ActionScript 3, you must use the
var
keyword.
- We then give it a unique name of our own choice so that we can distinguish if from other variables. In the code above I have called mine firstVariable.
- After our semi-colon we select a Data Type, this tells Flash what type of data is going to be stored in the above example I have used a STRING which indicates text or a string of characters.
- Inside the string I have typed Flash Essential
This is just one example of a data type but their are many more, over the course you will become more and more familiar with them so don't be to intimidated if you keep seeing unfamiliar and different data types. It will soon become second nature to you.
Some more variable examples
Notice I have named all the variables with a lowercase letter on the first word and a capital letter for the second word. These are some common practices when writing variables their are however other rules to take note of. They can only include alphanumeric characters and must only be one word.
So to conclude variables allows us to store data and use it later on in our code. It essentially gives our script a memory and the ability to remember types of data.
This post is tagged Actionscript 3, actionscript 3 beginners guide, variables
Share This Post
Jobs


























9 Comments
"After our semi-colon we select a Data Type"
I do believe you meant "colon". That ought to throw off some newbies.
From the Mind of Js last blog post..J’s Law. The linguistic phenomenon also known as the Beavis and Butt-Head principle.
nice man….
Incoming Links
Leave a Reply