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

Chapter 3. Managing Connections > Subclassing the NetConnection Class

3.6. Subclassing the NetConnection Class

You can extend the features of the NetConnection class by creating a subclass based on it. Creating subclasses lets you encapsulate code that operates on the NetConnection object within the subclass's methods such as connect( ), onStatus( ), or close( ). In turn, this can lead to more modular and easier to maintain applications. The key to doing this is to use the super operator. Example 3-8 shows a very simple example of how to extend the NetConnection class and then how to use it within a simple test script.

Example 3-8 uses AS 1.0 syntax so it works in both Flash MX and Flash MX 2004. This also allows you to compile using ActionScript 1.0 under File→ Publish Settings→ ActionScript. Example 3-10 provides an alternative implementation that uses AS 2.0 syntax and the v2 UI component's EventDispatcher class.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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