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 28. Loading External Display Ass... > Compile-Time Type-Checking for Runti...

28.2. Compile-Time Type-Checking for Runtime-Loaded Assets

In the earlier section "Section 28.1.4," we learned that the Loader class's instance variable content refers to an object representing a loaded asset. We also learned that—depending on which type of asset was loaded—content might refer to an instance of either the Bitmap class or a .swf file's main class. Instances of those disparate classes can legally be assigned to content because its datatype is DisplayObject, and both the Bitmap class and all .swf file main classes inherit from DisplayObject. As a result, any object assigned to content can be operated on using the variables and methods of DisplayObject but cannot be operated on using the more specific variables and methods of either the Bitmap class or a .swf 's main class.

For example, the following code legally accesses the DisplayObject class's instance variable width on an object referenced via content:


  

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