Thursday, December 4, 2008

Class and Function in AS3

Hi Guys,
This is my first tutorial in AS3.
The big change in AS2 and AS3 is Object Oriented Programming.

In AS3 all are considered as Object, Class. In this let me say What is Class ? , What is Object? , What is Package and their syntax.

Package:
Package is the collection of class. Class needs to be specified with in a package.

Syntax:
package
{
....
...
}

Class:
Class is the collection of function and variables.

Syntax:
class
{
...
...
}

type can be of 4 types : dynamic, final, internal, public where internal id default.

Object:
Object is the instance of class. Hear is the power of Object oriented programming by creating a single class we can create multiple objects.

var : = new ();

Example with all package, class, object...

//sample.as
package
{
class sample
{
sample()
{
trace("Hi");
}
}
}

//main.fla
var my_obj:sample = new sample();

Note : Both main.fla and sample.as must be in the same place.
Note : AS3 is case sensitive.

No comments: