logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA


dailyclick
All times in EST

Full Schedule
g
g Flash and Animation Site

BellaOnline's Flash and Animation Editor

g

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.

  4. Comments

    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 Del.icio.us 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


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 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


g features
Particle System - Emitter Shape Parameters

Motion Particle Systems - Introduction

Particle Fog in Motion 5 - Scene Graphics

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor