I'm using a text format to display text as 20 point Arial, and on the text field, I tell it to embed the font.?This should work since every windows system has Arial.
but the text doesn't show up... what am I missing?
here's code (yes, variables are declared and all that, this is just the parts of the code):
quesStemFormat = new TextFormat();
quesDistFormat = new TextFormat();
quesStemFormat.font = ''Arial'';
quesStemFormat.bold = true;
quesStemFormat.size = 20;
quesStemFormat.color = 0x000000;
stem = new TextField();
stem.x = 0;
stem.y = 0;
stem.defaultTextFormat = quesStemFormat;
stem.autoSize = TextFieldAutoSize.LEFT;
stem.embedFonts = true;
stem.wordWrap = true;
stem.multiline = true;
stem.selectable = false;
stem.condenseWhite = false;
stem.antiAliasType = AntiAliasType.ADVANCED;
stem.border = false;
stem.borderColor = 0xFF00FF;
stem.background = false;
stem.backgroundColor = 0x00FF00;
stem.text = ''This is the question stem'';
contentHolder.addChild(stem);
Be sure to include the embedded font as a new font in the library:
problems with text showing up.Have you tried putting the position .x and .y to different values e.g. .x = 100 and .y = 100?
I hadn't tried putting the x and y in a different position, but just did and didn't do anything... also embedded the font in the library and its still not showing up if I set embedFont to true...
Your settings for the library font should match my screen dump exactly.
This code works for me:
var quesStemFormat:TextFormat = new TextFormat();
var quesDistFormat:TextFormat = new TextFormat();
quesStemFormat.font=''Arial'';
quesStemFormat.bold=true;
quesStemFormat.size=20;
quesStemFormat.color=0x000000;
var stem:TextField = new TextField();
stem.x=0;
stem.y=0;
stem.defaultTextFormat=quesStemFormat;
stem.autoSize=TextFieldAutoSize.LEFT;
stem.embedFonts=true;
stem.wordWrap=true;
stem.multiline=true;
stem.selectable=false;
stem.condenseWhite=false;
stem.antiAliasType=AntiAliasType.ADVANCED;
stem.border=false;
stem.borderColor=0xFF00FF;
stem.background=false;
stem.backgroundColor=0x00FF00;
stem.text=''This is the question stem'';
contentHolder.addChild(stem);
Does it make a difference that its in an external class??That the only thing I can think of... but still haven't had this problem before...
You need to define an instance of the font in the library and then tell the textformat object to use that font. Have a look at the changes that I made to your code:
var quesStemFormat:TextFormat = new TextFormat();
var quesDistFormat:TextFormat = new TextFormat();
var myFont:Font = new Arial();
quesStemFormat.font=Arial.fontName;
quesStemFormat.bold=true;
quesStemFormat.size=20;
quesStemFormat.color=0x000000;
var stem:TextField = new TextField();
stem.x=0;
stem.y=0;
stem.defaultTextFormat=quesStemFormat;
stem.autoSize=TextFieldAutoSize.LEFT;
stem.embedFonts=true;
stem.wordWrap=true;
stem.multiline=true;
stem.selectable=false;
stem.condenseWhite=false;
stem.antiAliasType=AntiAliasType.ADVANCED;
stem.border=false;
stem.borderColor=0xFF00FF;
stem.background=false;
stem.backgroundColor=0x00FF00;
stem.text=''This is the question stem'';
addChild(stem);
No comments:
Post a Comment