embedded fonts using AS3 string
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
dynamic text x/y positions
Thanks for combining the embedded font + typewriter scripts, didn't know simply removing the line "myTextField.text = "The quick brown fox jumped over the lazy dog.";" would do the trick.
Problem I'm having now is that previously the dynamic text appeared in the text box called "textBox_txt" which was carefully positioned on the stage. Now however, the script is no longer associated with the what is on the stage so my text is running from the upper left corner.
Is there a way to point the text in the string to appear in the specific textField I have created on the stage? I'd rather not use AS3 to position the X and Y of the text because I already have text boxes of a particular shape and size on the stage throughout the piece.
Further help would be greatly appreciated!