Hi there!
I wanted to separate my embedded fonts to save filesize, so i’ve put them into sharedLib.SWF, and then preloaded sharedLib.SWF into flash using another SWF so that i could use these fonts further in multiple FLAs, without consuming additional bandwidth. I followed one tutorial, and checked out many different ones, to see if this issue occured to somebody else too. I had no luck finding the solution. Furthermore, i want to embed these fonts into AS-created textfields using AS.
ISSUE:
To embed preloaded fonts (there are 4 of them), i used this code:
var nNum:Number = 0;
// test of TF textFormatting:
for(var i:Number=0; i<2; i++){
for(var j:Number=0; j<2; j++){
this.createTextField("tf"+nNum, this.getNextHighestDepth(), 250, nNum*100+100, 200, 100);
var tf:TextField = this["tf"+nNum];
tf.autoSize = "center";
tf.selectable = false;
tf.text = "bliek";
tf.embedFonts = true;
//tf.wordWrap = false;
tf.border = true;
// create txtFormat for text
var my_fmt:TextFormat = new TextFormat();
// setTextFormat title according to nNum:
switch(nNum){
case 0: // 0
my_fmt.font = "eTahoma"; // should be unified
my_fmt.bold = false;
my_fmt.italic = false;
break;
case 1:
my_fmt.font = "eTahomaBold";
my_fmt.bold = true;
my_fmt.italic = false;
break;
case 2:
my_fmt.font = "eTahomaBoldOblique";
my_fmt.bold = true;
my_fmt.italic = true;
break;
case 3:
my_fmt.font = "eTahomaOblique";
my_fmt.bold = false;
my_fmt.italic = true;
break;
default: trace("Can't setTextFormat for TF nNum = "+nNum);
}
my_fmt.color = 0xffffff;
my_fmt.size = 20;
my_fmt.align = "center";
tf.setTextFormat(my_fmt);
nNum ++; // 0,1,2,3
}
}
Problem is, those fonts DO NOT get embedded, at all, leaving the textFields(TF) blank. Anybody, please enlighten me why is that so.
A LITTLE TRICK:
I tried to create 1 TF manually, and placed it on the Stage, setting its display text to one of the embedded texts (Tahoma*). This actually worked! And one more strange thing happened… Three of those TFs created using actionsctript, which were before blank, were NOW also filled with correct embedded text, EXCEPT one textfield which used Tahoma text non-bold, non-italic [!?]. Now how does this happen, and why the exception, i wonder…
Please, have a look at this FLA, there you can find ALL the files needed to test it yourself.
Thank You, thank you very much.