<?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>Flexpert to the rescue &#187; Flex</title>
	<atom:link href="http://www.flexpert.be/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexpert.be</link>
	<description>Blog site about all things Adobe</description>
	<lastBuildDate>Sat, 28 Aug 2010 17:07:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Milestone: the first video tutorial is online</title>
		<link>http://www.flexpert.be/2009/08/milestone-the-first-video-tutorial-is-online/</link>
		<comments>http://www.flexpert.be/2009/08/milestone-the-first-video-tutorial-is-online/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 15:14:12 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[video tutorial]]></category>
		<category><![CDATA[view state]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=250</guid>
		<description><![CDATA[It took me quite some time to figure out what it takes to make video tutorials: choose a subject, write a storyboard, prepare the entire story, record a zillion times &#8217;cause you&#8217;re never quite happy with the result, edit it afterwards, make a page to publish it, &#8230; And I&#8217;m probably forgetting a few steps [...]]]></description>
			<content:encoded><![CDATA[<p>It took me quite some time to figure out what it takes to make video tutorials: choose a subject, write a storyboard, prepare the entire story, record a zillion times &#8217;cause you&#8217;re never quite happy with the result, edit it afterwards, make a page to publish it, &#8230; And I&#8217;m probably forgetting a few steps now.</p>
<p>But all that hard work is now done for the first time, so it should become a little easier for the next couple of tutorials. So, if you fancy the visual side of tutorials instead of just reading the blog post, you can now view my very first one <a href="http://www.flexpert.be/video-tutorials/">here</a>. Of course, you can still read <a href="http://www.flexpert.be/flex/view-state-transition-problem-effects-dont-play/">the blog post</a> on the subject in the blog section of the Flexpert website.</p>
<p>Enjoy !!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2009/08/milestone-the-first-video-tutorial-is-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View state transition problem: effects don&#8217;t play</title>
		<link>http://www.flexpert.be/2009/07/view-state-transition-problem-effects-dont-play/</link>
		<comments>http://www.flexpert.be/2009/07/view-state-transition-problem-effects-dont-play/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 13:17:33 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[view state]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=126</guid>
		<description><![CDATA[Question: When I’m using view states, I apply transitions to make the view state changes more fluent an attractive. There seems to be a problem though, because when I have a component in the second view state that I want to fade out upon returning to the base state, that effect is never played. Do [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium;"><strong>Question:</strong></span></p>
<p><em>When I’m using view states, I apply transitions to make the view state changes more fluent an attractive. There seems to be a problem though, because when I have a component in the second view state that I want to fade out upon returning to the base state, that effect is never played. Do you have a clue why this doesn’t happen and if there a solution for this problem?</em></p>
<p><span style="font-size: medium;"><strong>Solution:</strong></span></p>
<p>If you are using view states and want to apply certain transitions between these states, there are some things to keep in mind. When adding components to a state, the transition effects (also called behaviors) are applied to that component while adding it. So this means that the effects will be visible during initialization of the view state. However, <strong>when you go back to the original base state, the component is removed again before the effects have had the chance of being displayed.</strong> Luckily, in Flex there are a couple of ways of dealing with this issue.</p>
<p>The <strong>first way</strong> of making sure the effects are visible is to not make use of a transition when going back to the base state. Instead, <strong>you use the effect triggers of the component itself to trigger the effect</strong>. When the component is removed, you need to use the <strong>removedEffect </strong>trigger like in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- The font needs to be embedded for the texxt to fade out</span>
<span style="color: #000000;">as well. Otherwise, the button will fade, but the text</span>
<span style="color: #000000;">will simply remain fully opaque througout the effect --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
@font-face {
src: local(&quot;Verdana&quot;);
fontFamily: myFont;
fontWeight: bold;
}
&nbsp;
global {
fontFamily: myFont;
}
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- This is the Fade effect we are going to use when the component is removed </span>
<span style="color: #000000;">          from the display list --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Fade</span> id=<span style="color: #ff0000;">&quot;fade&quot;</span> alphaFrom=<span style="color: #ff0000;">&quot;1&quot;</span> alphaTo=<span style="color: #ff0000;">&quot;0&quot;</span> duration=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Define the view state --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:states</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:State</span> name=<span style="color: #ff0000;">&quot;extraButton&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:AddChild</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- This button will fade in through the transitions and will fade out via the </span>
<span style="color: #000000;">          removedEffect trigger --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;btn2&quot;</span> label=<span style="color: #ff0000;">&quot;Click me now&quot;</span> click=<span style="color: #ff0000;">&quot;currentState=''&quot;</span> removedEffect=<span style="color: #ff0000;">&quot;{fade}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:AddChild</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:State</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Define the view state transition --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:transitions</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Transition</span> fromState=<span style="color: #ff0000;">&quot;&quot;</span> toState=<span style="color: #ff0000;">&quot;extraButton&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Fade</span> target=<span style="color: #ff0000;">&quot;{btn2}&quot;</span> alphaFrom=<span style="color: #ff0000;">&quot;0&quot;</span> alphaTo=<span style="color: #ff0000;">&quot;1&quot;</span> duration=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Transition</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:transitions</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- This component will be visible by default and triggers the second view state --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;btn1&quot;</span> label=<span style="color: #ff0000;">&quot;Click me&quot;</span> click=<span style="color: #ff0000;">&quot;currentState='extraButton'&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span>&amp;gt;</span></pre></div></div>

<p><br/></p>
<p>The problem with this approach is that the transition effects are scattered throughout your code. <strong>However, there is also a second, in my opinion more appropriate way of dealing with this transition problem and that is through the use of transitions.</strong> This means that all of your transitional code will be located in 1 spot and this is so much easier to maintain.</p>
<p>But how do we solve the issue of the effect not being shown? Well, in fact (and this is not often mentioned in books and courses), you <strong>do have total control of when an item is being added or removed considering the effects that need to be played on the component. </strong>To do this, you can simply use the <strong>&lt;mx:AddChildAction&gt;</strong> and <strong>&lt;mx:RemoveChildAction&gt;</strong> tags. Just place them in the right order within a &lt;ms:Sequence&gt; tag after the appropriate effect and your effect will be displayed properly. Just take a look at this example code:<</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- The font needs to be embedded for the texxt to fade out as well.</span>
<span style="color: #000000;">Otherwise, the button will fade, but the text will simply remain fully opaque</span>
<span style="color: #000000;">througout the effect --&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
@font-face {
src: local(&quot;Verdana&quot;);
fontFamily: myFont;
fontWeight: bold;
}
&nbsp;
global {
fontFamily: myFont;
}
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Define the view state --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:states</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:State</span> name=<span style="color: #ff0000;">&quot;extraButton&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:AddChild</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- This button will fade in and out through the transitions --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;btn2&quot;</span> label=<span style="color: #ff0000;">&quot;Click me now&quot;</span> click=<span style="color: #ff0000;">&quot;currentState=''&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:AddChild</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:State</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Define the view state transition --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:transitions</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Transition</span> fromState=<span style="color: #ff0000;">&quot;&quot;</span> toState=<span style="color: #ff0000;">&quot;extraButton&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Fade</span> target=<span style="color: #ff0000;">&quot;{btn2}&quot;</span> alphaFrom=<span style="color: #ff0000;">&quot;0&quot;</span> alphaTo=<span style="color: #ff0000;">&quot;1&quot;</span> duration=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Transition</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- The fade out effect is accomplished by adding a sequence with the </span>
<span style="color: #000000;">          RemoveChildAction after the effect --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Transition</span> fromState=<span style="color: #ff0000;">&quot;extraButton&quot;</span> toState=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Sequence</span> target=<span style="color: #ff0000;">&quot;{btn2}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Fade</span> alphaFrom=<span style="color: #ff0000;">&quot;1&quot;</span> alphaTo=<span style="color: #ff0000;">&quot;0&quot;</span> duration=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RemoveChildAction</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Sequence</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Transition</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:transitions</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- This component will be visible by default and triggers the second view state --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Buttonid</span>=<span style="color: #ff0000;">&quot;btn1&quot;</span> label=<span style="color: #ff0000;">&quot;Click me&quot;</span> click=<span style="color: #ff0000;">&quot;currentState='extraButton'&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p><br/></p>
<p>You can view the results of the latter solution in the application below.</p>
<p>
<object width="200" height="150">
<param name="movie" value="http://www.flexpert.be/swfexamples/Transitions.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="200" height="150" src="http://www.flexpert.be/swfexamples/Transitions.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2009/07/view-state-transition-problem-effects-dont-play/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding fonts in Flex, AIR and Actionscript projects</title>
		<link>http://www.flexpert.be/2009/06/embedding-fonts-in-flex-air-and-actionscript-projects/</link>
		<comments>http://www.flexpert.be/2009/06/embedding-fonts-in-flex-air-and-actionscript-projects/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 12:45:57 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[font]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=49</guid>
		<description><![CDATA[Question: I’m trying to develop a Flex application that uses a Text component which will take an html rendered text. So far, no problem there. However, I would like to use more than 1 font (regular, bold, italic) in this text component and I’m not sure if the fonts are all on the user’s computer. [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium;"><strong>Question:</strong></span></p>
<p><em>I’m trying to develop a Flex application that uses a Text component which will take an html rendered text. So far, no problem there. However, I would like to use more than 1 font (regular, bold, italic) in this text component and I’m not sure if the fonts are all on the user’s computer. What’s the best way of tackling this problem?</em></p>
<p><span style="font-size: medium;"><strong>Solution:</strong></span></p>
<p>If you don’t know for sure the fonts are installed on the user’s computer (because it’s some exotic font or some typical OS dependant font, the best way of dealing with that would be to embed the font in your Flex application (or any Actionscript application). Now, how do you do this exactly when you want to embed multiple fonts for a single component? Well, I’ll show you.</p>
<p>There are actually 3 ways of embedding your fonts in an application:</p>
<ol>
<li>embed fonts in your Actionscript code</li>
<li>embed fonts directly in CSS</li>
<li>embed fonts in CSS using a SWF file that has (part of) the fonts embedded</li>
</ol>
<p><strong>1. Embed your fonts directly in Actionscript</strong></p>
<p>To embed a font in Actionscript, you’ll have to assign it to some static variable to be able to incorporate it in the compilation of your application. Just before that variable definition, you specify a <strong>metadata tag “Embed”</strong> (just like you would if you were to embed an image). The properties for this metadata tag are:</p>
<ul>
<li>source: the location of your font file</li>
<li>fontName: the name you want to use in the application for your font. I’ve chosen to use myFont to indicate it can be anything you like. But you could also choose the font name itself if you prefer it like that</li>
<li>fontStyle: italic if it is an italic font (can be in combination with fontWeight)</li>
<li>fontWeight: bold if it is a bold font (can be in combination with fontStyle)</li>
<li>mimeType: e.g. application/x-font-truetype if it’s a truetype font</li>
</ul>
<p>Repeat this step for all the different fonts you want to embed, but <strong>make sure that the fontName property is exactly the same</strong> for all of them. So, when for example you want to embed a Verdana font in regular, bold, italic and boldItalic, your code would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;C:<span style="">\\</span>Windows<span style="">\\</span>Fonts<span style="">\\</span>Verdana.ttf&quot;</span>,
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span>,
       mimeType=<span style="color: #990000;">&quot;application/x-font-truetype&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static const VerdanaTTF<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;C:<span style="">\\</span>Windows<span style="">\\</span>Fonts<span style="">\\</span>VerdanaBold.ttf&quot;</span>,
       fontWeight=<span style="color: #990000;">&quot;bold&quot;</span>,
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span>,
       mimeType=<span style="color: #990000;">&quot;application/x-font-truetype&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static const VerdanaBoldTTF<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;C:<span style="">\\</span>Windows<span style="">\\</span>Fonts<span style="">\\</span>VerdanaItalic.ttf&quot;</span>,
       <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span>,
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span>,
       mimeType=<span style="color: #990000;">&quot;application/x-font-truetype&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static const VerdanaItalicTTF<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;C:<span style="">\\</span>Windows<span style="">\\</span>Fonts<span style="">\\</span>VerdanaBoldItalic.ttf&quot;</span>,
       fontWeight=<span style="color: #990000;">&quot;bold&quot;</span>,
       <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span>,
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span>,
       mimeType=<span style="color: #990000;">&quot;application/x-font-truetype&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static const VerdanaBoldItalicTTF<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;</pre></div></div>

<p><strong>2. Embed your font directly in CSS</strong></p>
<p>Now, you can do exactly the same using only an external CSS file. The embedding part itself is a little bit different though. You would have to use the @font-face style for each of the separate font styles you want to incorporate in the resulting SWF file and provide it with the following attributes:</p>
<ul>
<li>src: the location of your font file.</li>
<li>fontFamily: the name you want to use in your application for your font. Again, I’ve chosen to use myFont to indicate it can be anything you like. But you could also choose the font name itself if you prefer it like that</li>
<li>fontStyle: italic if it is an italic font (can be combined with fontWeight)</li>
<li>fontWeight: bold if it is a bold font (can be combined with fontStyle)</li>
</ul>
<p>The src style attribute can either point to a file on the local file system or to a file somewhere on the web or another location. For embedding a font which resides <strong>on the local file system, you would specify local(“&lt;font name&gt;”)</strong> . The font name will remain the same for all the variations you want to embed, because it’s the style attributes that will make up the difference here. You’ll probably use this local specification most of the time, because you’ll probably want to embed a font that you have on your own computer. However, if you were to incorporate a font file which resides somewhere <strong>on a remote location, you would use url(“&lt;path to font file&gt;”)</strong>. This path can either be a relative or absolute path.</p>
<p>Of course you need to <strong>repeat the @font-face style for every font variation you want to embed</strong>. Again, make sure that the fontFamily property is exactly the same for all of them, because you will use that name in the fontFamily attribute of the style you are going to apply on the component in order to use the different font styles.</p>
<p>For the same Verdana font definitions, your code should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> local<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Verdana&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> myFont;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> local<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Verdana&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> myFont;
	fontWeight<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">bold</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> local<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Verdana&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> myFont;
	<span style="color: #004993;">fontStyle</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">italic</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> local<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Verdana&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> myFont;
	fontWeight<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">bold</span>;
	<span style="color: #004993;">fontStyle</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">italic</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>3.	Use a SWF file with partially embedded fonts</strong></p>
<p>These first 2 methods work just fine. However, <strong>they do add several hundreds of kilobytes to your SWF file size</strong>. And this is only for 1 specific font, so imagine what it would do to a SWF file that compiles a couple of fonts into your application. This is due to the fact that a font is more than just alphabetical characters. Most of the time you don’t need all of those characters, but just the basic ones like digits, lowercase and uppercase letters and punctuation signs.</p>
<p>Fortunately, <strong>there is also another solution that allows you to limit the number of glyphs</strong> (this is what the individual font signs are called) to incorporate in your application. To be able to do this, we are going to have to take our development out of Flex Builder (or Flash builder of course) and bring it into Flash.</p>
<p>So, in Flash, you start by creating a <strong>new ActionScript 3 Flash file</strong>. On the stage, you <strong>place a text field</strong> and type some text. In the properties of that text field, you have to <strong>set it to Dynamic Text</strong>. In the Character subframe of the properties panel, you <strong>then select the font you want to embed as well as the style</strong> (regular, bold, italic or bold italic).</p>
<p><img class="aligncenter size-full wp-image-81" title="Properties panel" src="http://www.flexpert.be/wp-content/uploads/dynamic_text.jpg" alt="Properties panel" width="405" height="401" /></p>
<p>At the bottom of that same properties panel, you also see <strong>a button labeled “Character Embedding”</strong>. Just click on that one and you’ll get a dialog box which allows you to <strong>select the glyphs you want to embed</strong> in the Flash file. Select the uppercase, lowercase, numerals and punctuation glyphs and click ok to embed them in the SWF.</p>
<p><strong><img class="aligncenter size-full wp-image-87" title="Embed settings" src="http://www.flexpert.be/wp-content/uploads/embed.jpg" alt="Embed settings" width="304" height="399" /></strong></p>
<p>Now, perform the same procedure for the other font styles you want to embed, so you’ll eventually end up with 4 different dynamic text fields that all include a different style of your font.</p>
<p>The next step is then to <strong>compile your SWF file</strong>, so you can use it in your Flex or AIR application. To do that, you’ll first have to go to the Publish Settings, which you can find in the File menu. In the Format tab of the settings dialog, make sure that only Flash type is selected and then click on Publish. A SWF file will now be generated and that file will contain all the characters from the different font styles that you’ve just indicated.</p>
<p>Go back to Flex Builder (or Flash Builder of course) and <strong>add a fonts directory to your project</strong>. In this directory you place the SWF file that you have just generated. Now, to actually use the embedded fonts from the SWF file, <strong>we have to rely again on CSS</strong>. This is quite similar to the second method I’ve explained. However, <strong>this time the fontFamily property must be exactly the same as the actual font that you have included</strong>. So, in my example here, it has to be “Verdana”. You cannot choose the fontFamily name you want to use in your application freely anymore.</p>
<p>So, enter the different @font-face styles that match the embedded fonts from the SWF file in the same way as you would do when using the second method, bearing in mind that the font name is fixed now. Your code should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;../fonts/Verdana.swf&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> Verdana;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;../fonts/Verdana.swf&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> Verdana;
	fontWeight<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">bold</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;../fonts/Verdana.swf&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> Verdana;
	<span style="color: #004993;">fontStyle</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">italic</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000000; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;../fonts/Verdana.swf&quot;</span><span style="color: #000000;">&#41;</span>;
	fontFamily<span style="color: #000000; font-weight: bold;">:</span> Verdana;
	fontWeight<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">bold</span>;
	<span style="color: #004993;">fontStyle</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">italic</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>When you take a closer look at the generated SWF file, <strong>you will certainly notice a big difference in file size between the first 2 methods and this last one</strong>. This is because now, not all glyphs are embedded in the SWF file.</p>
<p>All you have to do now, is just set the fontFamily for the necessary components to the name you’ve just used in your CSS or Actionscript style embedding of the fonts, make sure you use the htmlText property and you’re all set to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2009/06/embedding-fonts-in-flex-air-and-actionscript-projects/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>The flexpert is in tha house</title>
		<link>http://www.flexpert.be/2009/06/the-flexpert-is-in-tha-house/</link>
		<comments>http://www.flexpert.be/2009/06/the-flexpert-is-in-tha-house/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 17:56:42 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[expert]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[flexpert]]></category>
		<category><![CDATA[Introduction]]></category>
		<category><![CDATA[question]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=38</guid>
		<description><![CDATA[Hi everyone, This is the very first post on this website to clarify a little bit what the flexpert is all about. This is by no means intended to be just another blog about Flex, AIR and LiveCycle related subjects. For techical matters on those things, I kindly refer to our company&#8217;s blog at http://blog.multimediacollege.be. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>This is the very first post on this website to clarify a little bit what the flexpert is all about. This is by no means intended to be just another blog about Flex, AIR and LiveCycle related subjects. For techical matters on those things, I kindly refer to our company&#8217;s blog at <a href="http://blog.multimediacollege.be" target="_blank">http://blog.multimediacollege.be</a>.</p>
<p>This site however is meant to be a site with specialist info on those topics with articles on demand. However, I&#8217;m not starting up a helpdesk website with trivial issues which can easily be found by using google. So please, no ordinary requests about how to structure a project or whether or not to use VBoxes and HBoxes. Every other technical or analytical request is welcome and I&#8217;ll try to write an interesting article about it, hoping the community can benefit from it.</p>
<p>If you have a request, please use the contact form on this website and I&#8217;ll try to convert it into an article as soon as possible.</p>
<p>So bring on those requests,</p>
<p>The flexpert</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2009/06/the-flexpert-is-in-tha-house/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
