Author: Ashwinee Kumar Dash.

Name of the Book: Essential ActionScript 3.0 by Colin Moock

Copyright: Creative Commons License
Disclaimer: Anything in quotation marks is a direct quotation from Essential
ActionScript 3.0
. All other notes are my own summaries of the concepts
presented in the book.

These notes are for reference purpose only and not intended to replace the book .Therefore I would strongly advise you to read the original book as well as make your own notes wherever necessary.

Send your suggestions and feedbacks to aswhineedash[at]gmail[dot]com or aswhinee2004[at]gamil[dot]com.

Classes

  • Classes are the blue prints upon which objects are built.
  • Every object that you see in a program has a class of its own.
  • Classes written from scratch known as custom classes.
  • Built in classes are used to perform some fundamental tasks
  • Classes built directly into ActionScript are known as native classes.
  • Classes are created by using class keyword.
  • class Identifier {

}

  • Name of the class should start with capital letter. Class name is known as Indentifier.
  • Class files should be saved with .as extension and the file name should match the class name.
  • All classes should reside in a package definition. A folder in that name should be created to contain the .as files.
  • To avoid a class conflicting with another class having the same name, it is defined within a package.
  • Package names start with small letters to distinguish from class names.
  • In ActionScript all program instructions are called directives.
  • A package definition can span multiple files but a class definition cannot span multiple files
  • Class in AS can have 4 attributes public, private, internal and static. The abstract property is not supported.
  • The main class must have public as its attribute set.
  • Internal is the default attribute.
  • If a class is meant to be used outside its package, it must be declared as public.
  • Internal means the class can be used inside the package only.
  • objects can be created out of classes by calling its constructor methods
  • If no constructor is provided, AS creates a default constructor. In this case no initialization takes place on new instances.
  • AS considers all constructor methods as public.
  • Codes in a given package can access the classes in that package only.
  • Code in a given package can refer to the classes in that package by their unqualified name i.e. name without their package name like com. className.
  • To use classes in other packages it must be imported first.
  • Once the class has been imported, it can be referred by its unqualified name.
  • Packages that have no name associated with them are placed in an automated created package Unnamed Package.These classes can be used in any where in the program without import directive.
  • Every object is considered as a self contained, single piece of data known as value.
  • Other legal values are null and undefined, they represent the concept of no value.
  • A variable is an identifier that refers to a value.
  • There are four types of variables: local variables, instance variables, dynamic instance variables and static variables
  • // Local variables//
  • Local variables track information temporarily within the confinement of a constructor method, an instance method, a static method or a function.
  • The variable definition starts with var keyword.
  • (Note) any directive that do not include a block statement ends with a semicolumn;
  • Value to a variable is assigned by using = sign.Both the = sign and value are known as variable initialiser.
  • When variable initialiser is missing actionscript assigns a default value.
  • The local variable expires once the function or the method that contains its definition is finished executing.
  • // Instance Variable//
  • Each object has got some characteristics that describe some aspect of that object. To keep track of an object’s characteristics, instance variables are used.
  • Instance variables are created using var keyword directly inside the class body. Once declared, it is directly attached to the instances automatically.
  • Instance variables can be and commonly set outside the class.
  • Four types of access control modifiers are available for instance variables. They are: public, internal, protected and private.
  • Instance variables having public attributes can be accessed both inside and outside of the package.
  • Instance variable declared internal can be accessed inside the package only. Internal is the default one.
  • Protected instance variables and private instance variables can be accessed by those classes where they have been defined. But the difference lies in subclasses accessing protected ones.
  • // constructor parameter //
  • Constructor parameters are variables that are declared and used as part of the construction method.
  • Assigning values to constructor parameters is known as passing values to variables.
  • Required parameter is the parameter whose value has not been initialized
  • At the instantiation of the class the required parameters must be passed.
  • An expression that contains variable’s name only is known as identifier expression
  • Within the body of the constructor method, this refers to the object created i.e. itself.
  • // Copies and references//
  • When the source variable is an instance of String, Boolean, int, uint, Number, ActionScript makes a copy of that variable and assigns the copy to the destination variable. In other cases it only refers to the original value.
  • Instance methods are functions that defines the actions of the object
  • Call expression is used to make the object perform the action.
  • Like instance variables, instance methods also got access control modifiers. They are public, private, protected and internal
  • As usual internal is the default one and it will be assigned unless anything else is specified. Internal is for package use only.
  • Public means it can be used outside the package.
  • Protected instance methods can be used inside the class and its subclasses only
  • Methods accepts values through their parameters
  • Methods also return values.
  • Method signatures include each parameter’s datatype and return type.

Advertisements