As3 Summary (2)

Source: Internet
Author: User
Tags addchild

1. Draw a drawing in as3. the first drawing will be overwritten by the later drawing.
2. Draw an irregular image and connect it with a line. To fill it with a line, you only need to set the fill color.
For example, draw a trapezoid with a gray border.
VaR ladder_draw: SPRITE = new sprite ();
VaR G: Graphics = ladder_draw.graphics;
G. linestyle (1, 0xff0000 );
G. beginfill (N );
G. moveTo (100,100 );
G. lineto (143,100 );
G. lineto (130,120 );
G. lineto (110,120 );
G. lineto (100,100 );
Ladder_draw.buttonmode = true;
Addchild (ladder_draw );
3. If you want to move the mouse over the drawn shape as a hand shape and it feels like a button, you can add an attribute to it.
Ladder_draw.buttonmode = true;
4. After a text box is added to the trapezoid, the set buttonmode is invalid. To solve this problem, you can add an attribute to the text box and set its mouse event to false.
Txt_draw.mouseenabled = false;
5. parse the attributes of the slide bar.
/* Instantiate a slide bar component first (Note: To generate a slide bar normally, you should first drag the slide bar in the component to the Flash file stage and then delete it to make it appear in the library )*/
Private var my_scb: scrollbar = new scrollbar ();
/* Set the direction attribute to scrollbardirection. Horizontal to a horizontal scroll bar, And scrollbardirection. Vertical to a vertical scroll bar */
My_scb.direction = scrollbardirection. vertical;
My_scb.x = 100;
My_scb.y = 100;
My_scb.height = 200;
My_scb.enabled = true;
// This is an important attribute. maxscrollposition is used to set the number of moving parts.
My_scb.maxscrollposition = 20;
// Add a mouse bullet event to the slider
My_scb.addeventlistener (mouseevent. mouse_up, AAA );
Addchild (my_scb );
/* Obtain the current position of the slider when the mouse is up, that is, the number of slides to the next time. Based on this value, you can set the current page number */
Private function AAA (Event: mouseevent ){
Trace (my_scb.scrollposition );
}

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.