Flash / Flex / ActionScript/TextField/autosize
Содержание
Sizing Text Fields to Fit Contents
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
// These two lines do the same thing
field.autoSize = flash.text.TextFieldAutoSize.LEFT;
// field.autoSize = true;
field.htmlText = "hello friend";
addChild(field);
}
}
}
TextFieldAutoSize.CENTER
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
field.autoSize = flash.text.TextFieldAutoSize.CENTER;
field.text = "text text text text text text text text text text text text text text text text text text text text text text text text text ";
addChild(field);
}
}
}
TextFieldAutoSize.LEFT
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
field.autoSize = flash.text.TextFieldAutoSize.LEFT;
field.text = "text text text text text text text text text text text text text text text text text text text text text text text text text ";
addChild(field);
}
}
}
TextFieldAutoSize.RIGHT
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
field.autoSize = flash.text.TextFieldAutoSize.RIGHT;
field.text = "text text text text text text text text text text text text text text text text text text text text text text text text text ";
addChild(field);
}
}
}