• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Objects and Classes > Instantiating Objects

12.2. Instantiating Objects

Although it may sound backward, let's assume that we have already created an object class. This assumption isn't too ludicrous, because ActionScript provides many built-in classes, and the custom classes we'll build will behave similarly. Assuming we have an object class, we have to create a specific object instance (i.e., a copy) based on the class. For example, ActionScript provides the TextField class, but it is up to us to create individual text fields.

To create an instance of an object (i.e., to instantiate the object), we normally use the new operator with a constructor function, which initializes the object. The general syntax is:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint