Flash MX ActionScript Banner Search Macromedia.com
shim.gif
Overview

Intro - Flash History

Flash ActionScript

Building User Interfaces

Object Oriented Techniques

Beyond Flash MX

Conclusion

Recommendations

References

Appendices

Author Notes

Figure Captions

Questions?

Email Dianne

shim.gif

Using Flash MX ActionScript

Object Oriented Techniques

What is an Object?

An object is an abstract representation of a thing or concept that programmers can use as containers for both data and code. With ActionScript we can set an object’s properties by specifying the object, and then naming the property, such as this example:

myMusic.style = “Jazz”;

According to Hall, the basic concepts of behind OOP (Object Oriented Programming) are objects, properties, methods, and classes (p. 34, 2002). If you want to learn more about Branden Hall's ideas you can go to his companion website for his OOP book at http://www.wheelmaker.org/.

Why use OOP in Flash?

Even when you are not using OOP with Flash movies you will still need to plan how your movies are going to be created. Each scene needs to be written out so you know how you are going to program or create the movie. Hall writes about the process of building Macromedia Flash applications is similar to building a house, and offers the following advice (at http://www.macromedia.com/devnet/mx/flash/extreme/extreme005.html, 2003):

  • Drawing the blueprints includes making a plan using the Model-View-Controller (MVC) pattern. This entails the model, which handles your application’s data; the view, which handles the visual interface; and the controller, which handles the user input.
  • Pouring the foundation which consists of the application data and accessor methods to retrieve and modify that data.
  • Framing, wiring, and plumbing consists of two pieces: the view (what the user sees and interacts with), and the controller (which handles user input – for example, validation).
  • Wallpaper and paint consists of making the application pretty, such as, adding backgrounds and colors.
  • OOP allows programmers to manage their project in smaller pieces, which allows the project to flow smoother.

How do you apply OOP in Flash?

By looking at the Flash environment as many objects of which you can use to build other objects you can use them to create the applications how you desire. Bhangal writes that the open-ended approach is not used much in classic OOP, but the freeform ‘create objects and then build other stuff on top of them in an open process’ is what Flash is all about (p. 391, 2002).

In Flash all objects are built upon what is called the Object object, and this is important because it is the base of all objects in Flash. Bhangal discusses that there are only two important things: the object > .property/method structure and scope (p.400, 2002):

  • All objects are fundamentally data structures, consisting of properties and methods. This structure is inherited from a base object called Object.
  • Some properties are expressed as data and some are expressed as visual attributes, but neither are special cases, because the code that controls a property is fundamentally the same, irrespective of what the effect of changing the property will be.
  • All objects conform to scope. There are two way of assigning scope, one of which is visual (e.g. attaching MovieClips, Buttons, and TextFields to a keyframe), and the other is programmatical (defining an object within a script that is also attached to a keyframe). Neither is a special case, and both are actually different ways of doing the same thing.
  • One object is unique because it has no scope and this is called _global. Rather than see this as a new object, it is better to see it as a special case of position (or scope= =null or scope = = everywhere, depending on how you prefer to see it). It is timeline-independent and therefore not a timeline itself, but a position. Objects that are global are not special cases, but simply normal objects in a special scope-less place.

Back to Top