[prev in list] [next in list] [prev in thread] [next in thread]
List: swftools-common
Subject: [Swftools-common] tip for embedding fonts and modifying text with actionscript
From: "Sairam Suresh" <sairam () flipclips ! com>
Date: 2007-09-27 1:39:08
Message-ID: 9363bb4c0709261839o1db36511l9eafcd73722140dc () mail ! gmail ! com
[Download RAW message or body]
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.
[Attachment #3 (text/html)]
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:<br><blockquote><font size="1"><span style="font-family: courier \
new,monospace;">
.flash bbox=420x240 <br> .font helvetica-light \
"helvetica-light.swf"</span><br style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;"> \
</span><br style="font-family: courier new,monospace;"> <span style="font-family: \
courier new,monospace;"> .sprite layer1</span><br style="font-family: \
courier new,monospace;"><span style="font-family: courier \
new,monospace;"> .action:</span><br style="font-family: courier \
new,monospace;"> <span style="font-family: courier \
new,monospace;"> \
this.createTextField("text_1",1,37,41,240,44);</span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> text_1.multiline = false; </span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> text_1.wordWrap = false;</span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> text_1.border = false;</span><br \
style="font-family: courier new,monospace;"><br style="font-family: courier \
new,monospace;"><span style="font-family: courier \
new,monospace;"> format_1 = new TextFormat();</span> \
<br style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> \
format_1.align="left";</span><br style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;"> \
format_1.font="helvetica-light";</span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> format_1.size=22;</span><br \
style="font-family: courier new,monospace;"> <span style="font-family: courier \
new,monospace;"> format_1.color = 0xFFFFFF;</span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> </span><br style="font-family: courier new,monospace;"> <span \
style="font-family: courier new,monospace;"> \
text_1.embedFonts = true;</span><br style="font-family: courier new,monospace;"><span \
style="font-family: courier new,monospace; font-weight: \
bold;"> text_1.text = _root.text1; </span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;"> \
text_1.setTextFormat(format_1);</span><br style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;"> \
.end</span><br style="font-family: courier new,monospace;"><span style="font-family: \
courier new,monospace;"> .end<br> <br> .put \
layer1<br><br>.end<br></span></font></blockquote><br>The resulting .swf can be called \
with the urlencoded parameter text1 like so: <br><br><a \
href="http://mydomain.com/test.swf?text1=blah+blah+blah">http://mydomain.com/test.swf?text1=blah+blah+blah</a><br><br>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 <span style="font-weight: \
bold;">text_1.embedFonts=true;</span> line I was always unsuccessful. \
<br><br>Hopefully this will save you some time if you're in the same boat.<br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic