Declaring variables in ActionScript 3

Filed in ActionScript 3 Lesson 1 Variables Basics 0 comments

Declaring variable is easy but like other OOP languages you must follow some rules
some times we may mention creating or defining avariable instead of declaring but both of them are correct
the syntax of declaring variables is as follows:

 var CustomName:DataType;
CustomName = value;

and a a varianble can also be declared and assigned with a value in a single line

 var CustomName:DataType = value;

Examples:

var nCustom:Number;
nCustom = 357;

or

var nCustom:Number = 357;

multiply avriables also could be declared in a single line

var CustomName1:DataType, CustomName2:DataType

Example:

var sName:String, var sFamilyNAme:String

lets anatomize every thing is used in this Example:

var nCustom:Number = 357;

var:in every variable declaration this keyword hs to be used followed by the name of the variable.in prevous versions of ActionScript it was option wether to use this keyword or not but after the version 3 and later you must use this keyword.
nCustom:this is the name of the variable which you are declaring. this could be any word r strings of letters and numbers which begin with an underscore or a letter.I have seen so many convention for naming variables,some are to begin a descriptive word with the datatype first letter in lowercase followed by your custom name with the beginning name in upercase.some will tell to have your beginning letter in lowercas with a descriptive word in upercase.
to name a variable that holds String value
sMyName
or you can name like this
MyName
it doesn’t matter how you name it and its upto you but there is some rules not to do is ,not to name your variableswith the kwywords or other special value that is recognized by ActionScript.
the name must be uniq.
:Number:this is the datatype that a varibale can hold.this “number” can be replaced by any other datatypes in actionscript.
357:this is the value that will be assigned to the variable.

Related posts:

  1. Understanding DataTypes in ActionScript 3
  2. Assigning Variables in PHP
  3. Variables default values in PHP
  4. PHP Variables Basic
  5. Reassigning Variables in PHP
Posted by voshka   @   1 March 2010 0 comments

Share This Post

RSS Digg Twitter StumbleUpon Delicious Technorati

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Previous Post
«
Next Post
»
CrossBlock designed by DeltaManual.Com  |  In conjunction with Web Hosting   |   Web Hosting   |   Reverse phone