Search Flex Samples

Working with objects

ActionScript is what's known as an object-oriented programming language. Object-oriented programming is simply an approach to programming--really nothing more than a way to organize the code in a program, using objects.

Earlier we defined a computer program as a series of steps or instructions that the computer performs. Conceptually, then, we might imagine a computer program as just a single long list of instructions. However, in object-oriented programming, the program instructions are divided among different objects--the code is grouped into chunks of functionality, so related types of functionality or related pieces of information are grouped together in one container.

In fact, if you've worked with symbols in Flash, you're already used to working with objects. Imagine you've defined a movie clip symbol--let's say it's a drawing of a rectangle--and you've placed a copy of it on the Stage. That movie clip symbol is also (literally) an object in ActionScript; it's an instance of the MovieClip class.

There are various characteristics of the movie clip that you can modify. For example, when it's selected there are values you can change in the Property inspector, like its x coordinate, or its width, or various color adjustments like changing its alpha (transparency), or applying a drop-shadow filter to it. Other Flash tools let you make more changes, like using the Free Transform tool to rotate the rectangle. All of these things that you can do to modify a movie clip symbol in the Flash authoring environment are also things you can do in ActionScript by changing the pieces of data that are all put together into a single bundle called a MovieClip object.

In ActionScript object-oriented programming, there are three types of characteristics that any class can include:

  • Properties
  • Methods
  • Events

Together, these elements are used to manage the pieces of data used by the program and to decide what actions are carried out and in what order.



Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples