Chapter II ActionScript 3.0 learning to draw stars (mouse and keyboard events)

Source: Internet
Author: User

Today I think it is more interesting to learn, so record it ... ~ ~ ~

The following paragraph is the code that paints the stars:

Package {Import Flash.display.shape;import Flash.display.gradienttype;public class Starshape extends Shape {public function Starshape (X:number = 5, Y:number = innerradius:number, Points:int =, = +, Outerradius:number =-angle): Number = 0, Color:uint = 0xff0000) {//x and Y are the starting point ~~var count = Math.Abs (points); (2, 0x85db18);// Start Fill color (color), if (Count > 2) {//init Varsvar step, Halfstep, start, N, DX, dy;//calculates the distance between two points step = (M Ath. PI * 2)/points;halfstep = step/2;//start angle start = (angle/180) * Math.pi; (x + (Math.Cos (start) * out)  Erradius), Y-(Math.sin (START) * Outerradius));//Draw The Edge for (n = 1; n <= count; n++) {dx = x + math.cos (start + (step *) of the star graph) N)-halfstep) * Innerradius;dy = Y-math.sin (start + (STEP * N)-halfstep) * Innerradius; (dx, dy); DX = x + math.cos (start + (step * N)) * Outerradius;dy = Y-math.sin (start + (step * N)) * Outerradius; to (dx, DY);}};}}} 

The following results are shown:

Mouse click and keyboard press event exercises (press the button is Alt,shift,ctrl, single or 22 combination, three together, click the mouse):

Package {Import Flash.display.sprite;import;import;import;import;import;import;import Flash.text.textfield;public class Samplesendandload extends Sprite {private var _ Result:textfield;public function Samplesendandload () {//Create a text box object, return to session after successful login Id_result = new TextField (); _ Result.autosize = "Left"; _result.wordwrap = True;_result.width = 300;addchild (_result);//login information, including user name and password var loginxml: XML = <login><username></username><password>actionscript 3</password>< /login>;var request:urlrequest = new URLRequest (""); Request.contenttype = "Text/xml"; = Loginxml.toxmlstring (); Request.method =;var Loader:URLLoader = new URLLoader (); Loader.addeventlistener (Event.complete, Completehandler); try {trace ("Loading ..."); Loader.load ( request);}catch (Error:argumenterror) {trace ("parameter Error");} catch (Error:securityerror) {Trace ("Security error occurred"); _result.text = "A security error occurred. \ n "+ Error;}} Private Function Completehandler (event:event): void {trace (; var resultxml:xml = new XML (; _result.text = [email protected];}}


Can test the above click Results Oh, Hee ~ ~ Beginner Notes!! Don't puke, Auntie.

Chapter II ActionScript 3.0 learning to draw stars (mouse and keyboard events)

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: 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.