<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Interactive IQ : The Hessler Design Blog &#187; text format</title>
	<atom:link href="http://www.hesslerdesign.com/blog/tag/text-format/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hesslerdesign.com/blog</link>
	<description>Smart Developers = Smart Websites</description>
	<lastBuildDate>Thu, 26 Jan 2012 23:00:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Creating a Gradient Fill on Dynamic Text in Flash ActionScript 3.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 18:22:20 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[text format]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=667</guid>
		<description><![CDATA[The other day, I had a revelation. It was a moment a lot like the Microsoft commercials, where I pictured myself slightly better looking (3 inches taller, perfect hair, and more muscular), coming to a moment of self-realization&#8230;. Or something like that. Maybe you’ve already figured this out, maybe not. Either way, I think it’s [...]]]></description>
			<content:encoded><![CDATA[<p>The other day, I had a revelation. It was a moment a lot like the Microsoft commercials, where I pictured myself slightly better looking (3 inches taller, perfect hair, and more muscular), coming to a moment of self-realization&#8230;. Or something like that.  Maybe you’ve already figured this out, maybe not.  Either way, I think it’s pretty sweet.</p>
<p>Here’s what my realization entailed:</p>
<p>As some of you may know, I’m always a big fan of keeping live text — be it static or dynamic — in Flash files, so that when I or anyone needs to go back in and make an update, it can be done w/o opening a Photoshop file, slicing and dicing image(s), and importing them into Flash.  Not only is it easier, but it&#8217;s a tremendous help in keeping file size down.</p>
<p>One aspect that is sometimes difficult is when a design calls for an effect on text, such as a gradient.  In Flash, we’re all probably aware that you can create a static text field and a shape (such as a gradient box), set the text field on the layer above said shape, and right-click the text layer to set it as a mask over the shape.  But here&#8217;s where my realization came…</p>
<div style="margin: 18px 0px; text-align: center;"><em><strong><span style="font-size: 150%; line-height: 130%;">“Why stop there?  This same effect can be done with pure ActionScript.”</span></strong></em></div>
<p>It&#8217;s very true — this same effect can be done with pure ActionScript, for more dynamic scenarios&#8230; or if you&#8217;re one of those people who hate the stage with a passion.  All I’d need to do in the code is create a text field and a gradient box, layer them appropriately, and set the text as the mask on the gradient box.  And, since you can embed fonts in Flash (see the previous post about <a title="Embedding Fonts Using ActionScript 3.0" href="http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-3-0/" target="_blank">Embedding Fonts Using ActionScript 3.0</a>), it can be done with any crazy display font that a design calls for (Immi 505 in the example below).</p>
<p>With that in mind, I put together a little demo to prove to myself (and you) that it was as easy as I thought it would be.  The demo has an input text field that you can use to change and update the text &#8212; which happens on the fly each time the input field is updated (so you know it&#8217;s truly live and dynamic, and not slight of hand).  So go ahead and play around with it.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="546" height="124" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/dynamicGradientText.swf" /><embed type="application/x-shockwave-flash" width="546" height="124" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/dynamicGradientText.swf"></embed></object></p>
<div style="margin-bottom:24px;"><small><em>Note: In this demo, the text field is set to single line with 28 character max, and its width is currently hard-coded.   This is all for the sake of the fact that it’s a demo, and to keep things neat and tidy.  It’s easy to base the width of the text field and gradient box to be based on the &#8220;textWidth&#8221; property of the text field, for even more coding nirvana.  And with only a little more effort (duplicating your gradient box and repositioning its y position based on the line height of the text field), you can do multiline text with the same gradient on each line, though it would definitely take some more tweaking and massaging based on the individual font, line height, font size, etc.</em></small></div>
<p>So there you have it.  Dynamic text with a gradient fill effect.  Easy peasy, eh?</p>
<p>Until next time, happy coding!</p>
<h4>Download</h4>
<p>What&#8217;s that, you say? You want to see the source code to make this work? Well, ask and ye shall receive. Just click the button below to download the source FLA and AS file for this demo.</p>
<div style="margin-top:24px;"><a href="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/11/DynamicGradientText.zip"><img class="aligncenter size-full wp-image-426" title="Download Sample" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/btn_downloadSample.png" alt="Download Sample" width="150" height="29" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Embedding Fonts Using ActionScript 3.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-3-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-3-0/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 17:05:31 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[text format]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=137</guid>
		<description><![CDATA[If you read my previous post on Embedding Fonts Using ActionScript 2.0, you&#8217;ll remember that I didn&#8217;t cover embedding fonts in ActionScript 3.0 in that post. So now, I&#8217;ll take you through the steps necessary to embed fonts in your ActionScript 3.0 files. As we did when embedding in ActionScript 2.0, you&#8217;ll need to make [...]]]></description>
			<content:encoded><![CDATA[<p>If you read my previous post on Embedding Fonts Using ActionScript 2.0, you&#8217;ll remember that I didn&#8217;t cover embedding fonts in ActionScript 3.0 in that post. So now, I&#8217;ll take you through the steps necessary to embed fonts in your ActionScript 3.0 files.</p>
<p>As we did when embedding in ActionScript 2.0, you&#8217;ll need to make a new Font item in your Library.  Click on the Library menu, and select &#8220;New Font&#8230;&#8221;.  Find your Font and Style from the dropdown menus in the dialog box, and give it a unique name.  I generally give it a name that includes reference to both the Font and Style (in this example, I am using RockwellBold).  Then, make sure the &#8220;Export for ActionScript&#8221; checkbox is checked under the Linkage section of the dialog box, which will auto-check the &#8220;Export in frame 1&#8243; checkbox.  Lastly, give your new Font a unique identifier in the &#8220;Class&#8221; field beneath the checkboxes.  I like to make this Class the same as the Name I gave it above.  Once all that is done, click OK.  </p>
<p><i>(Note: You may get a dialog box that tells you, &#8220;A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export.&#8221;  This is fine.  It&#8217;s just telling you that the Class you identified isn&#8217;t a built-in Flash Class.  As long as you don&#8217;t need to access additional functionality beyond that of the Font class, you don&#8217;t have to worry.)</i></p>
<p><a href="http://www.hesslerdesign.com/blog/wp-content/uploads/2009/09/embed_font_dialog_as3.jpg"><img class="size-full wp-image-138" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2009/09/embed_font_dialog_as3.jpg" alt="" width="566" height="495" /></a></p>
<p>Next comes the ActionScript:</p>
<p><code><span style="color: #0000ff;">var</span> rockwellBold:<span style="color: #0000ff;">Font</span> = <span style="color: #0000ff;">new</span> RockwellBold <span style="color: #0000ff;">as Font</span></code>;<br />
<code><span style="color: #0000ff;">var</span> rockwellBoldTF:<span style="color: #0000ff;">TextFormat</span> = <span style="color: #0000ff;">new TextFormat</span>();</code><br />
<code>rockwellBoldTF<span style="color: #0000ff;">.font</span> = rockwellBold.<span style="color: #0000ff;">fontName</span>;</code></code></p>
<p><code>myText_txt<span style="color: #0000ff;">.text</span> = <span style="color: #009900;">"Hello World!"</span>;</code><br />
<code>myText_txt<span style="color: #0000ff;">.setTextFormat</span>(rockwellBoldTF);</code><br />
<code>myText_txt<span style="color: #0000ff;">.embedFonts</span> = <span style="color: #0000ff;">true</span>;</code><br />
<code>myText_txt<span style="color: #0000ff;">.antiAliasType</span> = <span style="color: #0000ff;">AntiAliasType.ADVANCED</span>;</code></p>
<p>First, we create a new Font object, and assign it to our Font Class we created above (RockwellBold).  Then, we create a new <code>TextFormat</code>, and give it the <code>font</code> attribute with the name of the Font object you just created, appended with <code>fontName</code> property.  Then, set the text of your text field ("Hello World!").  After setting the text, use the <code>setTextFormat</code> attribute, and pass in the <code>TextFormat</code> variable you created in the first line.  Next, set the <code>embedFonts</code> attribute to "<code>true</code>".  Lastly, you can optionally set the <code>antiAliasType</code> attribute of your text to either <code>ADVANCED</code> or <code>NORMAL</code>.  By anti-aliasing your text, you effectively smooth the edges of your font to avoid any distortion artifacts that may be introduced through screen display.  According to Adobe's documentation, the <code>ADVANCED</code> setting is most useful for applications that have a lot of small text, and isn't recommended for font sizes above 48 pts.  The <code>NORMAL</code> setting is most useful for applications that don't have a lot of text, and sets the anti-aliasing to the setting that was used in Flash Player 7.  Once these steps are done, you're all set.</p>
<p>As with embedding fonts in AS 2.0, it's nothing too complicated.  Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Embedding Fonts Using ActionScript 2.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-2-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-2-0/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 14:18:37 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 2]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[text format]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=130</guid>
		<description><![CDATA[I work on a number of Flash websites that require specific fonts to be used, most of which aren&#8217;t part of the list of common fonts normally found on computers. While this isn&#8217;t a huge deal for static text, it does pose a problem for dynamic and input text fields, especially when you make text [...]]]></description>
			<content:encoded><![CDATA[<p>I work on a number of Flash websites that require specific fonts to be used, most of which aren&#8217;t part of the list of common fonts normally found on computers.  While this isn&#8217;t a huge deal for static text, it does pose a problem for dynamic and input text fields, especially when you make text fields on the fly using ActionScript.  Below you&#8217;ll find how to embed fonts into your Flash movie using ActionScript 2.0.</p>
<p>To start, you&#8217;ll need to make a new Font item in your Library.  Click on the Library menu, and select &#8220;New Font&#8230;&#8221;.  Find your Font and Style from the dropdown menus in the dialog box, and give it a unique name.  I generally give it a name that includes reference to both the Font and Style (in this example, I am using RockwellBold).  Then, make sure the &#8220;Export for ActionScript&#8221; checkbox is checked under the Linkage section of the dialog box, which will auto-check the &#8220;Export in frame 1&#8243; checkbox.  Lastly, give your new Font a unique identifier in the &#8220;Identifier&#8221; field beneath the checkboxes.  I like to make this Identifier the same as the Name I gave it above.  Once all that is done, click OK.</p>
<p><a href="http://www.hesslerdesign.com/blog/wp-content/uploads/2009/08/embed_font_dialog_as2.jpg"><img class="size-full wp-image-131" title="embed_font_dialog_as2" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2009/08/embed_font_dialog_as2.jpg" alt="Embed fonts dialog box" width="568" height="497" /></a></p>
<p>Next comes the ActionScript:</p>
<p><code><span style="color: #0000ff;">var</span> rockwellBoldTF:<span style="color: #0000ff;">TextFormat</span> = <span style="color: #0000ff;">new TextFormat</span>();</code><br />
<code>rockwellBoldTF<span style="color: #0000ff;">.font</span> = <span style="color: #009900;">"RockwellBold"</span>;</code></p>
<p><code>myText_txt<span style="color: #0000ff;">.text</span> = <span style="color: #009900;">"Hello World!"</span>;</code><br />
<code>myText_txt<span style="color: #0000ff;">.setTextFormat</span>(rockwellBoldTF);</code><br />
<code>myText_txt<span style="color: #0000ff;">.embedFonts</span> = <span style="color: #0000ff;">true</span>;</code></p>
<p>First, we create a new <code>TextFormat</code>, and give it the <code>font</code> attribute with the name of the Font in your Library that you just created.  Then, set the text of your text field (&#8220;Hello World!&#8221;).  After setting the text, use the <code>setTextFormat</code> attribute, and pass in the <code>TextFormat</code> variable you created in the first line.  Lastly, set the <code>embedFonts</code> attribute to &#8220;<code>true</code>&#8220;, and you&#8217;re all set.</p>
<p>As you no doubt noticed, it&#8217;s nothing too complicated to embed fonts.  I&#8217;d also urge you to explore more of the options of text formatting, colors, etc.  And while this example uses ActionScript 2.0, make sure you keep an eye out for a post on how to make it happen in ActionScript 3.0.  Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

