g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Natural Living
Folklore and Mythology
Distance Learning

All times in EST

Full Schedule
g Flash and Animation Site

BellaOnline's Flash and Animation Editor


Naming Variables and Other Syntax Rules for ActionScript

In a previous tutorial, we discussed how to create a variable in FlashR ActionScript 3. You learned that you can use the var keyword to define a variable. In this tutorial, you will learn some rules for naming your variables as well as some basic syntax rules for ActionScript.

var name_of_variable = value;

Basically, you can give any name to your variable but there are a few rules that you need to follow.

  1. Each variable name must be unique which means any name can only be used once.

  2. Variable names are case-sensitive which means that a capital letter is not the same as a lowercase letter. For example, "CAT" is not the same as "cat".

  3. A variable name cannot begin with a number.

  4. Variable names can contain only numbers, letters and the underscore.

  5. Some words are already used by Flash and cannot be used for any other purpose. These special words are called keywords. For example, the "word" var is a keyword and cannot be used as a name for your variable.

Since we are talking about rules, let's take a look at a few basic syntax rules for ActionScript.

  1. Each line of code ends with a semi-colon.

    If you take a look at the line of code above, you will notice that it ends with a semi-colon. A semi-colon is used to end a line of code much like a period ends a sentence.

  2. Parenthesis ( )
    Brackets [ ]
    Curly Brackets { }

    Parenthesis, brackets and curly brackets are used in pairs. Every opening parenthesis, bracket or curly bracket must have an accompanying closing parenthesis, bracket or curly bracket.

  3. Strings and quotation marks.

    A sentence such as "My name is Mary." is called a string. In ActionScript, strings must be enclosed within quotation marks. When you place a string between quotation marks, you are telling the program where the string begins and ends. The first quotation mark begins the string and when the program encounters a second quotation mark, it knows to end the string.


    Every programmer has his or her opinion as to what information should be included within the program code. Most programmers add comments with their code in order to remind themselves, and anyone else, what the code does and how it does it. When deciding what information to include ask yourself what you would need to be told about the program if someone else had written the program and now you were asked to run and maintain it.

    If your comment is only one line, you will begin that line with two backslashes.

    // Your comment goes here

    If your comment has more than one line, you will begin the comment with "/*" and end it with "*/".

    /* First line of comments.
    Second line of comments. */

Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Twitter Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Facebook Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to MySpace Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Digg Naming+Variables+and+Other+Syntax+Rules+for+ActionScript Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Yahoo My Web Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Google Bookmarks Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Stumbleupon Add Naming+Variables+and+Other+Syntax+Rules+for+ActionScript to Reddit


RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the Flash and Animation Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2018 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.


g features
Subtle Animation Website Trends

Wix Editor - Background Video

Video on Wix Websites

Archives | Site Map


Past Issues

Note: BellaOnline uses cookies to help provide a consistent user experience. Our advertisers may use cookies to help customize ads. Please contact us with any question about our cookie use.

Summertime Foods
Corn on the Cob
Burgers on the Grill
Apple Pie


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2018 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor