Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

Chapter 15. Dynamic ActionScript > Using Functions to Create Objects

15.5. Using Functions to Create Objects

As we've seen throughout this book, most objects in ActionScript are created using classes. However, it is also possible to create objects using standalone function closures. The following code shows the basic approach. It uses an example function, Employee( ), to create an object:

// Create the function
function Employee () {
}

// Use the function to create an object, and assign that
// object to the variable, worker
var worker = new Employee();


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial