TextField_restrict_maxChars
♥0 |
Line 25 |
Modified 2009-09-04 15:19:05 |
MIT License
archived:2017-03-09 22:14:47
ActionScript3 source code
/**
* Copyright oshige ( http://wonderfl.net/user/oshige )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/nzcv
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class MyTextField extends Sprite {
public function MyTextField(){
//テキストの書式
var tf:TextFormat = new TextFormat();
tf.font = "_typewriter";
tf.size = 18;
//テキスト入力フィールドの作成
var fld:TextField = new TextField();
fld.type = TextFieldType.INPUT;
fld.defaultTextFormat = tf;
//文字種の制限
fld.restrict = "_.0-9a-zA-Z";
//最大文字数の制限
fld.maxChars = 25;
fld.x = 100;
fld.y = 50;
fld.width = 300;
fld.height = 24;
fld.border = true;
addChild(fld);
}
}
}