The small package of TextField in as3.0 makes it a good input box

Source: Internet
Author: User
Tags addchild

package mycomponent {import flash.display.shape;import flash.display.sprite;import  flash.text.textfield;import flash.text.textfieldtype;import flash.text.textformat;import  Flash.text.textlinemetrics;public class myinput extends sprite{private var _ Mytextfield:textfield  = new textfield ();//Text field of a text box Private var mysprite:sprite  = new sprite ();p rivate var _defaultvalue:string =  ' hello ';//Default value private  var _backgroudcolor:uint = 0xffffff;//text box background color    default to white Private var _ Default length of Paddingwidth:uint = 120; //textfield Private var _aspassworlddisplay:boolean   = false;//whether to display private var _bordercolor:uint  = 0xd4d4d4;//as a password box Input border color private var _bordersize:uint = 1;//input border size Private var _paddinghorizontalval : uint = 1;//TextField and border inside the input borderDistance private var _paddingverticalval:uint = 2;//the upper and lower distance of the TextField and border within the input border private var _ borderradius:uint = 2;//the corner radius of the four corners of the input border private var _textfontsize:uint = 16; // Set the font size in TextField private var _textfontcolor:uint = 0x000000;//set the font color in TextField private  var _textFontFamily:String =  ";//Set the font in TextField public function myinput ()  {}private function inittextfield (): Void {    this.mytextfield.type  = textfieldtype.input;//setting TextField is an input this.mytextfield.text = this._defaultvalue;// Set the default input for TextField     //set the font in TextField var myformat:textformat = new  TextFormat (); myformat.size = this._textfontsize;myformat.color = this._textfontcolor;if   (!this._textfontfamily)  {myformat.font = this._textfontfamily;} This._mytextfield.settextformat (MyFormat);//Set TextField backgroundColor This.mytextfield.background = true;this.mytextfield.backgroundcolor = this._ backgroudcolor;//Setting the TextField's length and width this.mytextfield.width = this._paddingwidth ;var  Textlineinfo:textlinemetrics = this.mytextfield.getlinemetrics (0);this.mytextfield.height   = textlineinfo.ascent +textlineinfo.descent + 4;// Whether to display this.mytextfield.displayaspassword = this._aspassworlddisplay;//as a password box var bordershape: Shape = new shape ();             BorderShape.graphics.lineStyle (This._bordersize, this._bordercolor); BorderShape.graphics.drawRoundRect (0,  0, this._paddingwidth+this._paddinghorizontalval*2, this.mytextfield.height +this._ Paddingverticalval*2, this._borderradius, this._borderradius); This.addchild (borderShape);// Set the location of the TextField this.mytextfield.x = this._paddinghorizontalval;this.mytextfield.y&Nbsp;= this._paddingverticalval;this.addchild (This._mytextfield);} Public function initdraw (): Void {this.inittextfield ();} Public function get defaultvalue (): String {return _defaultvalue;} Public function set defaultvalue (value:string): Void {_defaultvalue = value;} Public function get backgroudcolor (): Uint {return _backgroudcolor;} Public function set backgroudcolor (value:uint): Void {_backgroudcolor = value;} Public function get paddingwidth (): Uint {return _paddingwidth;} Public function set paddingwidth (value:uint): Void {_paddingwidth = value;} Public function get aspassworlddisplay (): Boolean {return _aspassworlddisplay;} Public function set aspassworlddisplay (Value:boolean): void {_aspassworlddisplay =  value;} Public function get bordercolor ():Uint {return _bordercolor;} Public function set bordercolor (value:uint): Void {_bordercolor = value;} Public function get bordersize (): uint {return _bordersize;} Public function set bordersize (value:uint): Void {_bordersize = value;} Public function get paddinghorizontalval (): Uint {return _paddinghorizontalval;} Public function set paddinghorizontalval (value:uint): void {_paddinghorizontalval =  value;} Public function get paddingverticalval (): Uint {return _paddingverticalval;} Public function set paddingverticalval (Value:uint):void {_paddingverticalval =  Value;} Public function get mytextfield (): Textfield {return _mytextfield;} Public function set mytextfield (Value:textfield): Void {_mytextfield = value;} Public function get textFontSize (): uint {return _textfontsize;} Public function set textfontsize (value:uint): Void {_textfontsize = value;} Public function get textfontcolor (): Uint {return _textfontcolor;} Public function set textfontcolor (value:uint): Void {_textfontcolor = value;} Public function get textfontfamily (): string {return _textfontfamily;} Public function set textfontfamily (value:string): Void {_textfontfamily = value;}}}


This article is from my It career blog, so be sure to keep this source http://quietnight.blog.51cto.com/7163892/1676372

The small package of TextField in as3.0 makes it a good input box

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.