http://www.bhmadhukar.cjb.net


[ MORE TUTORIALS] [ GOD AND GODDESS SLOKA'S & POOJA'S ] [ FLASH MOVIES ] [ HOME ] [ CONTACT ME ]


Flash 5.5 Tutorials


Flash 5.5 tutorial - [ Beginners ]

Know More About variables in Flash.

Creating a variable is called declaration. When a variable is first declared, it is empty. In this state, a variable contains a special value called undefined (i.e., indicating the absence of data).

We can declare a variable by using "Var" keyword.

for example;

Var ClientName;
Var PosX;

The word "Var" tells the interpreter that we are declaring a variable, and the text that follows, such as ClientName, PosX becomes our new variable's name. We can create variables anywhere. We can attach code on a keyframe, a button or a movie clip.

We can also declare several variables with one Var statement, like this:

Var x, y, z;

Valid Variable Names:

>> Must be composed of letters, numbers, and underscores. It should not include spaces, hyphens, or punctuation allowed.

>> Must start with a letter or an underscore (_).

>> Must not exceed 255 characters.

>> It must be case insensitive (upper and lowercase are treated identically, but you should be consistent nonetheless).

Some of the valid variable names:

var FName;
var Speed;
var AccountNumber;

These are illegal variable names that would cause errors:

var 1x; // starts with a number
var f name; // it contains spaces
var f-name; // it contains a hyphen

Now, let's see how we can assign the values to a variabe;

syntax: VariableName = Value;

where VariableName is the name of the variable and Value is the data that is assigned to the variable.

example:

var FName;
FName="Flash Action Scriptng Code";

Similary, we can assign a value to multiple variables;

var x,y,z;
x = y = z = 30;

Let us see a small example. Follow the steps;

1. If you already opened Flash Application, select first keyframe on "Layer 1" or Named-Layer or any, right-click on that keyframe (fig-1). A pop-up will apear. Select "Actions". Figure shown below (fig-2),


fig-1

2. You will see below figure. There are two modes to operate-on. a) Normal Mode & b) Expert Mode. Right-click on that arrow and choose Expert Mode (below figure).


fig-2

3. You will see fig-3.


fig-4

4. Write given below code there:

var AuthorName;
AuthorName="BHMK";
trace ("Hello! How Are You, " + AuthorName);

5. Press "Ctrl+Enter" to test the Movie;

6. You will see as shown in the figure. This is how you can test.


fig-5

Checking Whether a Variable Has a Value

Occasionally, we may wish to verify that a variable has been assigned a value before we make reference to it. For example, a variable has been declared, but never assigned a value; contains undefined. To determine whether a variable has been assigned a value, we compare that variable's value to the "undefined" keyword.

For example:

if (anyVariable != undefined)
{
        // write any code
}

Know about datatypes in Flash [ View Content ]

That's all my dear friends. Hope You Enjoyed It!!! Don't forget send mail to me.


"Fundamentals are the Route to the Destination" - BHMK

Go Home


Hosted by www.Geocities.ws

1