Create complex style buttons in ActionScript

Source: Internet
Author: User

The pure as code Drawing Method of microui can make FLASH small, but the first version is not flexible enough. Each set of skin needs to be re-implemented by itself.

The new version wants to be more flexible and provides custom options for Corner, shadow, edge, gradient effect, and other style details. This may remove the skin function and add the style sheet function.

A prototype project was created in the evening to verify the feasibility. A pure code drawing and a imitation thunder skin Download button were used.

Comparison of results is as follows:

Thunder New Drawing code

Comparison of new and old drawing codes:

Microui 0.1 New Drawing code

The complete code is as follows:

Package {import flash. geom. matrix; import flash. text. textfield; import flash. text. textfieldautosize; import flash. filters. dropshadowfilter; import flash. display. sprite; import flash. display. movieclip; import flash. display. gradienttype;/*** a prototype for microui ** @ author bg5sbk * @ link www.microui.org */public class microui_prototype extends sprite {public function microui_prototype () {var matrix: matrix = new matrix (); var button: movieclip = new movieclip (); // the outter bordermatrix. creategradientbox (80, 23, math. PI/2); button. graphics. begingradientfill (gradienttype. linear, [0x5bb5d8, 0x278fc6], [1, 1], [0,255], matrix); button. graphics. drawroundrect (0, 0, 80, 24, 8, 8); button. graphics. endfill (); // The inner bordermatrix. creategradientbox (78, 21, math. PI/2); button. graphics. begingradientfill (gradienttype. linear, [0x60c8f1, 0x5aafe7], [1, 1], [0,255], matrix); button. graphics. drawroundrect (1, 1, 78, 22, 6, 6); button. graphics. endfill (); // The backgroundmatrix. creategradientbox (76, 19, math. PI/2); button. graphics. begingradientfill (gradienttype. linear, [0x44bdee, 0x329ade], [1, 1], [32,255], matrix); button. graphics. drawroundrect (2, 2, 76, 20, 4, 4); button. graphics. endfill (); // The textvar text: textfield = new textfield (); text. textcolor = 0 xffffff; text. TEXT = "Download skin"; text. selectable = false; text. mouseenabled = false; text. mousewheelenabled = false; text. autosize = textfieldautosize. center; text. X = (button. width-text. width)/2; text. y = (button. height-text. height)/2; button. addchild (text); // The shadowvar shadow: dropshadowfilter = new dropshadowfilter (1, 90, 0xa7bcd6, 1, 2, 2); button. filters = [shadow]; button. X = (stage. stagewidth-button. width)/2; button. y = (stage. stageheight-button. height)/2; addchild (button );}}}

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.