Tuesday, May 6, 2008

Object In Action Script 3

Action Script is an OOP(Object Oriented Programming) language in which code is well organized. In OOP the primary focus is on object. Earlier programming was seen as mehod in which user gives some input, computer process it and the gives output. The whole process involves series of instructions where the code may repeat many times. Object can be a flower which has the properties like color, smell etc. Where as class is the collection of all the flowers in the world which have the same properties. In action script there are any class can have the following characterestics :
  • Properties
  • Methods
  • Events

Properties are the group of data binded togather with object. As explained above a flower object might have the properties like smell, color, shape etc. Similarly the movie clip class has the properties like rotation, alpha, scale etc. In the following example the code scales the movie clip fly to the double of its existing size.

fly.scaleY=2;

The syntax can be: object.property=value

This whole structure is taken as a single variable and stored in a memory as a single value.

Method is an action that instructs object to do a perticular task. Suppose we have a movieclip named fly which has its separate timeline and contains some animation on it. Then we can instruct this movie clip to play by using the following code:

fly.play() where the fly is a movie clip object and play is the method.

As we know that Action Script is a programming language which is used with flash for creating interactive application and websites. This interaction involves event. When user click on some element we can set how it will respond on thhat event.

No comments: