Simple plotting program implemented by event

Source: Internet
Author: User
Package ...{
/**//**
* Simple plotting program implemented by event
*
**/
Import flash. display. Sprite;
Import flash. display. stagescalemode;
Import flash. display. stagealign;
Import flash. Events. mouseevent;

Import flash. Events. keyboardevent;
Import flash. Text. textfield;
Import flash. system. system;
Import flash. system. capabilities;
Import flash.net. filereference;

Public class asproject extends Sprite
...{
Private VaR _ sprite: SPRITE;
Public Function asproject ()
...{

Initialize ();
Showinfo ();
Stage. scalemode = stagescalemode. no_scale;
Stage. align = stagealign. top_right;
Stage. showdefaconcontextmenu = false;

Graphics. beginfill (0 xffffff );
Graphics. drawrect (0, 0, stage. stagewidth, stage. stageheight );
Graphics. endfill ();

/** // * Browse local files */
VaR filereference: filereference = new filereference ();
Filereference. Browse ();
}

Public Function showinfo (): void
...{
/** // * Display local system information */
VaR TXT: textfield = new textfield ();
VaR osinfo: String = "OS:" + capabilities. OS;
TXT. Text = osinfo;
Addchild (txt );
TXT. appendtext ("version:" + capabilities. Version + "language:" + capabilities. Language
+ "Manufacturer:" + capabilities. Manufacturer );

}
Public Function initialize (): void
...{
Stage. Focus = this;
Addeventlistener (keyboardevent. key_down, onkeydown );
_ Sprite = new sprite ();
Addchild (_ sprite );
}

Public Function draw (): void
...{
_ Sprite. Graphics. beginfill (0 xffffff );
_ Sprite. Graphics. drawrect (0, 0, 400,400 );
_ Sprite. Graphics. endfill ();
_ Sprite. addeventlistener (mouseevent. mouse_down, onmousedown );
_ Sprite. addeventlistener (mouseevent. mouse_up, onmouseup );

}
/**//*
Private function onenterframe (Event: Event): void
{
Graphics. lineto (math. Random () * 400, math. Random () * 400 );
}
*/
Private function onkeydown (Event: keyboardevent): void
...{
Trace ("key down:" + event. charcode );
}
Private function onmousedown (Event: mouseevent): void
...{
_ Sprite. Graphics. linestyle (1, 0, 1 );
_ Sprite. Graphics. moveTo (mousex, Mousey );
_ Sprite. addeventlistener (mouseevent. mouse_move, onmousemove );

}
Private function onmousemove (Event: mouseevent): void
...{
_ Sprite. Graphics. lineto (mousex, Mousey );

}
Private function onmouseup (Event: mouseevent): void
...{
_ Sprite. removeeventlistener (mouseevent. mouse_move, onmousemove );
}
}
}

 

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.