|
From: | Sairam Suresh |
Subject: | [Swftools-common] Re: tip for embedding fonts and modifying text with actionscript |
Date: | Thu, 27 Sep 2007 04:11:38 -0700 |
For those bashing their heads against dynamically adding/modifying text blocks in actionscript with fonts embedded by swfc, here's a snippet of code that might help you out:.flash bbox=420x240
.font helvetica-light "helvetica-light.swf"
.sprite layer1
.action:
this.createTextField("text_1",1,37,41,240,44);
text_1.multiline = false;
text_1.wordWrap = false;
text_1.border = false;
format_1 = new TextFormat();
format_1.align="left";
format_1.font="helvetica-light";
format_1.size=22;
format_1.color = 0xFFFFFF;
text_1.embedFonts = true;
text_1.text = _root.text1;
text_1.setTextFormat(format_1);
.end
.end
.put layer1
.end
The resulting .swf can be called with the urlencoded parameter text1 like so:
http://mydomain.com/test.swf?text1=blah+blah+blah
Of course, this seems like the long way around when swfc provides most of that functionality for you, but when I was writing a function in actionscript that needed a particular embedded font, without the text_1.embedFonts=true; line I was always unsuccessful.
Hopefully this will save you some time if you're in the same boat.
[Prev in Thread] | Current Thread | [Next in Thread] |