About the drawing

Source: Internet
Author: User

 

    1. You can use flash. display. Graphics to draw a flex drawing.

The graphics class has a series of functions to create vector graphics. The Display object supports drawing of Sprite and shape objects. These classes contain graphics attributes of the graphics type. For example, the drawrect () function, drawroundrect () (rounded rectangle), drawcircle () (Circular), drawellipse () (elliptical ).

However, graphics objects cannot be directly instantiated from The ActionScript language. An exception is thrown when new is directly used to instantiate graphics objects. The graphics class is final and cannot be inherited.

This attribute is included in Sprite and shape.

For exampleCode:

VaR child: Shape = new
SHAPE ();


Child. Graphics. beginfill (bgcolor );

Child. Graphics. linestyle (bordersize,
Bordercolor );


Child. Graphics. drawroundrect (0, 0, size, size, cornerradius );


Child. Graphics. endfill ();

Addchild (child );

This code must be written in the class inherited from displayobjectcontainer.

 

    1. In the above example, the class containing graphics objects is used for drawing, and graphics objects are inherited from shape or Sprite. There is also a way to draw an image to a bitmap.

The steps for this method are as follows:

()
Create a bitmapdata object

(B)
Call bitmapdate.
Draw (Source: ibitmapdrawable, matrix: matrix = NULL,
Colortransform: Flash. Geom: colortransform = NULL,
Blendmode: String = NULL,
Cliprect: rectangle = NULL,
Smoothing: Boolean = false): void

In this function, many classes implement the ibitmapdrawable interface, including textfield and graphics.

(C)
Create a bitmap object and use bitmapdata for initialization.

Bitmap(Bitmapdata: bitmapdata = NULL, pixelsnapping: String = "Auto", smoothing: Boolean = false)

(D)
Use displayobjectcontainer and its subclass to call addchild (Child: displayobject): displayobject to add a bitmap object.

Advantages and disadvantages:

Advantage: bitmap is flexible, occupies a small amount of resources, and is fast.

Disadvantage: bitmap has a size limit. So pay attention to it. Otherwise, an exception occurs during running.

In air 1.5 and Flash Player 10,
Maximum size for a bitmapdata object is 8,191 pixels in width or height, and
The total number of pixels cannot exceed 16,777,215 pixels. (So, if
Bitmapdata object is 8,191 pixels wide, it can only be 2,048 pixels high.) in
Flash Player 9 and earlier and Air 1.1 and earlier, the limitation is 2,880
Pixels in height and 2,880 pixels in width. If you specify a width or height
Value that is greater than 2880, a new instance is not created.

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.