 Z-G Tern
Moderator  Posts: 16
|
Variable
A variable represents a specific piece of data, which may or may not be constant. When you create, or declare, a variable, you also assign a data type, which determines what kind of data the variable can represent. For example, a String variable holds any string of alphanumeric characters, while a Number variable must contain a number.
Suppose you wanted to assign a variable to count the number of frames in a movie. You could name the variable frames, assign an initial value of 0, and set the script to add 1 when it moves to another frame.
var frames = 0;
currentframes = frames + 1;
Note
Variable names must be unique, and they are case-sensitive. The variable frames is not the same as the variable Frames. Variable names can contain only numbers, letters, and underscores, and they cannot begin with a number. For example, you can name a variable frames_2 or frames2, but not 2frames or frames 2.
Keyword
In ActionScript, a keyword is a reserved word that is used to perform a specific task. For example, var is a keyword, used to create a variable.
You can find a complete list of keywords in Flash Help. Because these words are reserved, you can't use them as variable names or in other ways. ActionScript always uses them to perform their assigned tasks.
Parameters
Parameters provide specific details and are the values between parentheses () in a line of code. For example, in the code gotoAndPlay(3); the parameter instructs the script to go to frame 3.
Function
A function is a group of statements that you can refer to by name. Using a function makes it possible to run the same set of statements without having to type them repeatedly into the same script.
For example, you could script a button to scale a movie clip by a certain percentage. The script might contain three lines. That's fine for one button, but if you want five buttons to perform the same task, you can create a function that contains three lines, and then refer to the function name to apply those lines of code for each button.
Class
In ActionScript 3.0, every object is defined by a class, which is an abstract representation of an object. You've already worked with MovieClip and Button classes in Flash. A class is a category of objects that share the same methods and properties. For example, if Dog is a class, its properties include four legs, fur, and a tail.
ActionScript contains more than 100 built-in classes, which are the predefined data types you use to make things work. To access the methods and properties associated with a class, you have to create an instance of the class by declaring the variable and setting its data type.
Scope
The scope defines the area in your Flash file in which a variable can be referenced: local, global, and timeline. Local variables are referenced only in a certain area, such as a frame or a function. As soon as that area stops executing, the local variable no longer exists. In a function, a local variable is declared between the curly brackets {}.
Global variables are available anywhere at any time to anything. You can declare a global variable and then use it in other frames as well as in other SWF files or movie clips that are loaded into the main movie file.
Timeline variables are available only to any script within the same Timeline. After a variable is declared on a Timeline, it is available to all the frames that follow.
Methods
Methods are the keywords that result in action. For example, two methods associated with the MovieClip class are stop() and gotoAndPlay().
Properties
Properties describe the object in a class. For example, the properties of a movie clip include its height and width, x and y coordinates, and scale.
|
|