I am making a little flash game for a project at school. Because for some reason it didn't work with creating a textfield in the design, I created the textfield with this piece of code:
var literWater = 1250;
var gramGraan = 1000;
nogDoen.text = "Je moet nog "+literWater+" liter water en "+gramGraan+" gram graan verplaatsen.";
Now what I can't figure out, is how to change the font of this textfield. I would like it to be something like Arial, 30pt. How should I do this?
Thanks in advance!
you must use the textformat class to create a new textformat instance. you can then assign properties (font and size) to the textformat instance and finally assign the textformat instance to your textfield. also, you must embed your font in your library which is a several step process.
your actionscript should look something like:
var tfor:TextFormat = new TextFormat();
tfor.font = "ArialID"; // this must match a font's linkage id in your library
tfor.size = 30;
var tf:TextField = this.createTextField("tf",1,0,0,300,40);
tf.embedFonts = true;
tf.setNewTextFormat(tfor); // or use setTextFormat() if you're assigning text before assiging tfor to tf
thanks a lot!
I already had something like that, but I think I just did one thing wrong or something.