AS3 Display object

Source: Internet
Author: User

DisplayObjectClass is the base class of all objects that can be placed in the display list. That is, the visual objects displayed on the swf stage inherit DisplayObject. Next we will look at a subclass inheritance class diagram of DisplayObject.

 

 

 

DisplayObjectSubclass AVM1Movie, Bitmap, InteractiveObject, MorphShape, Shape, StaticText, and Video. Here we will mainly introduce InteractiveObject !! Maybe you have already found out that InteractiveObject is born with a mother, which reminds me that my major at school is just like TMD ....).

 

InteractiveObjectYou can view the api. (It is recommended that you use the api frequently here. This will help you improve your performance. Maybe you know! _ = )., The InteractiveObject class is an abstract base class for all the displayed objects that you can interact with by using the mouse and keyboard. The meaning of this sentence is inherited from InteractiveObject, you will have the interaction function with the mouse and the keyboard (to put it bluntly, you can communicate with the mouse and the keyboard, and then .. No ...)! Are you OK?

 

InteractiveObjectThe subclasses of are DisplayObjectContainer, SimpleButton, and TextField. They allow users to use the mouse and keyboard to interact with all the display objects. That is to say, you can listen to addEventListener mouse events and Keyboard Events ).

 

DisplayObjectContainerClass is the base class for displaying all objects in the object container in the display list. This display list manages all objects displayed in Flash Player or Adobe AIR. Its subclass is Loader, Sprite, stage, TextLine. That is to say, all class objects inherited from DisplayObjectContainer can add other display objects to this container. You need to check the api help documentation frequently. Frequently Used APIs include addChild, addChildAt, removeChild, removeChildAt, and setChildIndex. You can view all of Mina's APIs in detail !!

 

SimpleButtonI seldom use it, so I will not introduce it. If you need to know about it, you can continue to view the api documentation. It should be noted that addChild, the display objects added and removed by removeChild are inherited from DisplayObject, that is, as long as they are inherited from DisplayObject, they can be added or removed from the display container.

 

TextFieldClass is used to create a display object to display and input text. All dynamic text fields and input text fields in the SWF file are examples of TextField classes. If you want to create text, you can use TextField to display the text you want to display, we can use the TextField instance to display it. You can view the api, view the instances in the api, and try to create some text on the swf stage.

 

LoaderClass can be used to load SWF files or images (JPG, PNG, or GIF) files, use load()Method to start loading. The loaded Display object is added as a child of the Loader object. YEAH !! Because Loader inherits the Display object, we can add the Loader instance to the display list to display and pull it directly. Here is a frequent error. When we listen on whether an image or swf file is loaded to Event. COMPLETE, we cannot directly use the Loader instance to add it. We can check that Event. COMPLETE is not found in the Event api of Loader.

 

We can use LoaderInfoClass to listen; The loaderInfo object can be referenced through the LoaderInfo attribute of the DisplayObject class, or the LoaderInfo object can be referenced through the contentLoaderInfo attribute of the Loader class.

 

SpriteObjects are similar to video clips, but there is no timeline. Sprite is a base class for objects that do not require timeline. This class is frequently used. When creating a project, our entry class inherits from Sprite, generally, you need to inherit Sprite when creating a display object. It has the Graphics attribute, and only the Shape and Sprite of all display objects have the Graphics function.

 

StageClass represents the main drawing area. For SWF Content running in a browser (using Flash Player), Stage indicates the entire area of the Flash content. For content running in AIR, each NativeWindow object has a Stage object. Stage objects cannot be accessed globally. Instead, you must use the DisplayObject instance's stageAttribute. The Stage class has multiple ancestor classes-DisplayObjectContainer, InteractiveObject, DisplayObject, and EventDispatcher. attributes and methods are inherited from these classes. Many of the attributes and methods inherited from these do not apply to Stage objects, or require security checks when calling Stage classes. The attributes and methods that require security check are recorded as part of the Stage class. (From the official API. For more details, see API ).

 

BitmapClass indicates the Display object of the bitmap image, which can be flash. display. for images loaded by the Loader class, the bitmap class is actually a potential force stock. There is a lot of room for optimization on its foundation, and the most direct is the performance of Flash Player.

 

ShapeThis class is used to create a simple shape using the ActionScript drawing application programming interface (API. Shape class includes graphicsThis attribute allows you to access methods from the Graphics class. Sprite classes also include graphicsAnd it includes other functions that cannot be used for the Shape class. For example, a Sprite object is a display object container, while a Shape object is not (and cannot contain a child Display object ). Because of this, Shape objects consume less memory than Sprite objects that contain the same image. However, Sprite objects support mouse-click events, while Shape objects do not.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.