Core display classes
The openfl.display package includes classes for visual objects that can appear in OpenFL. The following illustration shows the subclass relationships of these core display object classes.
The illustration shows the class inheritance of display object classes. Note that some of these classes, specifically StaticText, TextField, and Video, are not in the openfl.display package, but they still inherit from the DisplayObject class.
All classes that extend the DisplayObject class inherit its methods and properties. For more information, see Properties and methods of the DisplayObject class.
You can instantiate objects of the following classes contained in the openfl.display package:
Bitmap—You use the Bitmap class to define bitmap objects, either loaded from external files or rendered through Haxe. You can load bitmaps from external files through the Loader class. You can load GIF, JPG, or PNG files. You can also create a BitmapData object with custom data and then create a Bitmap object that uses that data. You can use the methods of the BitmapData class to alter bitmaps, whether they are loaded or created in Haxe. For more information, see Loading display objects and Working with bitmaps.
Loader—You use the Loader class to load external assets (either projects or graphics). For more information, see Loading display content dynamically.
Shape—You use the Shape class to create vector graphics, such as rectangles, lines, circles, and so on. For more information, see Using the drawing API.
SimpleButton—A SimpleButton object is the OpenFL representation of a button symbol created in the Flash authoring tool. A SimpleButton instance has four button states: up, down, over, and hit test (the area that responds to mouse and keyboard events).
Sprite—A Sprite object can contain graphics of its own, and it can contain child display objects. (The Sprite class extends the DisplayObjectContainer class). For more information, see Working with display object containers and Using the drawing API.
MovieClip—A MovieClip object is the OpenFL form of a movie clip symbol created in the Flash authoring tool. In practice, a MovieClip is similar to a Sprite object, except that it also has a timeline. For more information, see Working with movie clips.
The following classes, which are not in the openfl.display package, are subclasses of the DisplayObject class:
- The TextField class, included in the openfl.text package, is a display object for text display and input. For more information, see Using the TextField class.
- The Video class, included in the openfl.media package, is the display object used for displaying video files.
The following classes in the openfl.display package extend the DisplayObject class, but you cannot create instances of them. Instead, they serve as parent classes for other display objects, combining common functionality into a single class.
InteractiveObject—InteractiveObject is the base class for all objects used to interact with the mouse and keyboard. SimpleButton, TextField, Loader, Sprite, Stage, and MovieClip objects are all subclasses of the InteractiveObject class.
MorphShape—These objects are created when you create a shape tween in the Flash authoring tool. You cannot instantiate them using Haxe, but they can be accessed from the display list.
Stage—The Stage class extends the DisplayObjectContainer class. There is one Stage instance for an application, and it is at the top of the display list hierarchy. To access the Stage, use the stage property of any DisplayObject instance. For more information, see Setting Stage properties.
Also, the StaticText class, in the openfl.text package, extends the DisplayObject class, but you cannot create an instance of it in code. Static text fields are created only in SWF-based assets.