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

Chapter 14. Introduction to Object-Orien... > Creating Custom Prototype Objects

Creating Custom Prototype Objects

For the majority of small projects, using Flash’s built-in objects is more than sufficient. Occasionally though, especially with larger projects, you might need to create custom prototype objects. Why would you need to do this? You might be working with information that lends itself very nicely to being treated as an object. For example, say you need to develop a check-in, check-out system for your local library. What does a library have in abundance? Books, of course. You could create a Book object; Flash doesn’t have one of those. Each book has properties, such as a title, an author, a year of publication, and so on. But what about methods? What kinds of methods would a book have? Well, if you need to check a book in or out, you would need a method to handle that. Any time you are dealing with a collection of related information, you should be thinking about how that information could be grouped in an object.

Unlike with class-based OOP languages, in ActionScript there is no command that explicitly says “the code beneath me defines a blueprint.” In ActionScript, you simply build the various parts of the object and then tie them together at the end.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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