I’m having difficulty positioning text created at run-time using font symbols (one for each of the Textformat’s).
Can someone show me what’s wrong?
Thanks…
Here’s the code:
(Requires 3 font symbols in the Library: Artist_Choice, Artist_Choice_bold, and Artist_Choice_bold_italic)
var SW:Number = Stage.width;
var SH:Number = Stage.height;
//setup a font format that will serve as our base font
var basalFormat:TextFormat = new TextFormat();
//basalFormat Textformat;
var bFormat:TextFormat = new TextFormat();
//bFormat Textformat;
var biFormat:TextFormat = new TextFormat();
//biFormat Textformat;
var biFormatCenter:TextFormat = new TextFormat();
//biFormatCenter Textformat;
//If you are using font symbols, make sure that the font symbols are linked and exported in the first
//frame.
//
function makeFormatting():Void {
basalFormat.font = "Artist_Choice";
basalFormat.size = 23;
basalFormat.align = "left";
//basalFormat.color = 0xC90E12;
//
bFormat.font = "Artist_Choice_bold";
bFormat.size = 34;
bFormat.bold = true;
bFormat.align = "justify";
//bFormat.color = 0xF26522;
//
biFormat.font = "Artist_Choice_bold_italic";
biFormat.size = 11;
biFormat.bold = true;
biFormat.italic = true;
biFormat.align = "right";
//biFormat.color = 0xFFCC00;
//
biFormatCenter.font = "Artist_Choice";
biFormatCenter.size = 44;
biFormatCenter.bold = true;
biFormatCenter.italic = true;
biFormatCenter.align = "center";
//biFormatCenter.color = 0x007236;
//
this.createEmptyMovieClip("txtHolder",this.getNextHighestDepth());
}
//
function createTxt(txtFieldName:String):Void {
var formatArrays:Array = new Array();
formatArrays = [basalFormat, bFormat, biFormat, biFormatCenter];
for (var i = 0; i < 4; i++) {
txtHolder.createTextField(txtFieldName + i,i,0,0,SW,0);
var textF:TextField=txtHolder[txtFieldName + i];
textF.autoSize = "left";
textF.multiline = true;
textF.wordWrap = true;
textF.embedFonts = true;
textF.antiAliasType = "advanced";
textF.gridFitType = "subpixel";
//thickness is from -200 to 200
textF.thickness = 25;
//sharpness is from -400 to 400
textF.sharpness = 65;
textF.type = "input";
textF.selectable = false;
textF.text = "This be paragraph "+i+". "+"This is the text to follow: tionum illa feui eugait, suscinim il utet utat.";
textF.border = true;
textF.setTextFormat(formatArrays*);
textF._x = (SW / 2) - (textF._width / 2);
// textF._y = (textF._height);
trace (" textF._y: "+textF._y);
}
// txtHolder._x = (SW / 2) - (txtHolder._width / 2);
// txtHolder._y = (SH / 2) - (txtHolder._height / 2);
}
//
makeFormatting();
createTxt("sometext");