O'Reilly logo

Learning Flex 4 by Elijah Robison, Alaric Cole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Classes

If everything is an object, then what is a class? A class is like a blueprint for an object. Classes define the properties and methods an object will have. Accordingly, a class variable is just an in-memory container representing an instance of a class.

If you want to follow along with the examples in this section, you may want to create a new project in your workspace. We called this project ClassTesting.

Packages

ActionScript classes expect to belong to a particular package. A package is simply a unique folder structure that stores source code files for various classes. Flash Builder will allow you to maintain a package anywhere in your filesystem, so we’ll take advantage of that.

Using whatever method you prefer, create the following folder structure in your workspace; again, we’re showing C:\Flex4Code\ as the workspace:

C:\Flex4Code\com\learningflex4\classes

Note

By convention, package names should be all lowercase.

This means your workspace should include a folder named com, which includes the folder learningflex4, which includes the folder classes.

With a folder structure set up for our custom package and a new project ready to go, we’re ready to link the package into our project. Make sure the project is selected in the Package Explorer, and choose Project→Properties→Flex Build Path. Then, click the “Source path” tab, followed by the Add Folder button.

In the Add Folder dialog, browse to the com folder in your workspace and add it (Figure 5-6).

Figure 5-6. Adding a package as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required