Hello,

I am using an AS3 typewriter script that uses a string to have a bit of dynamic text appear like it is being typed across the screen and it works great, however because the text that appears is part of a String rather than a TextField, the embedded font is not functioning.

I have tried to combine the typewriter script together with one using a text field, however I am unable to pull off both the embedded font and the typewriter action.

Can anyone help me to embed a font for a dynamic text that is a string?


Here are the two scripts I'm working with:

#1 typewriter script:

var str:String = 'PASSING THROUGH'
var i:uint = 0;
var timer:Timer = new Timer (60);
timer.start();

timer.addEventListener(TimerEvent.TIMER,gotime);

function gotime(e:TimerEvent) {
textBox_txt.appendText(str.charAt(i));
i++;
if(i>=str.length){
timer.stop();}
}

#2 embedded font script:

var myFont:Font = new EmbeddedFont();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;
myFormat.size = 24;

var myTextField:TextField = new TextField();
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.defaultTextFormat = myFormat;
myTextField.embedFonts = true;
myTextField.text = "The quick brown fox jumped over the lazy dog.";
addChild(myTextField);


Thanks in advance for any insight here!

-Llyfre