<?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>Sun, 05 Feb 2012 21:58:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Do Flex and LiveCycle still have a future?</title>
		<link>http://www.flexpert.be/2011/12/do-flex-and-livecycle-still-have-a-future/</link>
		<comments>http://www.flexpert.be/2011/12/do-flex-and-livecycle-still-have-a-future/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 10:19:03 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[LiveCycle Data Services]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Flash player]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[LiveCycle]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=962</guid>
		<description><![CDATA[I&#8217;ve been quiet for quite some time now. There are 2 reasons for that. The first one is simply because I have been busy on a couple of projects and just didn&#8217;t find the time to write another blog post. The second reason is that I wanted to wait and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been quiet for quite some time now. There are 2 reasons for that. The first one is simply because I have been busy on a couple of projects and just didn&#8217;t find the time to write another blog post. The second reason is that I wanted to wait and see what would happen with all of the bad news around Flex and LiveCycle. I did not want to overreact, as many other people have done, causing a temporary wide spread panic about Flash being killed.
<p>I completely agree that it has been poor communication from Adobe, especially after what they have announced at AdobeMAX this year. So, timing could have been better and the messages that they initially shared could have been better formulated. Adobe acknowledges this and have sent out their apologies for that as well. But the harm was already done. I even saw people leaving prerelease and other programs (I can&#8217;t mention by name) furious about what happened and turning their backs on Adobe entirely. I respect those decisions, but come on, is it really such a bad thing?</p>
<p><strong>For those of you who are not quite up to speed on what exactly is going on at Adobe. Let me briefly state the latest developments.</p>
<ul>
<li>Adobe is dropping the Flash player on mobile devices</li>
<li>Flex is going to become completely open source</li>
<li>LiceCycle will be discontinued after the next release</li>
<li>AIR on mobile (iOS, Android, PlayBook) is still going to be developed</li>
<li>Flash Builder will continue to be developed by Adobe</li>
<li>The next version of Flash Builder will not have a Design View</li>
<li>The DCD feature will be dropped in the next release of Flash Builder</li>
</ul>
<p></strong></p>
<p>Let&#8217;s start with LiveCycle. For those of you who don&#8217;t know what LiveCycle is, it is a product that allows you to define information workflows, mainly based on PDFs. So, for example, you could fill out a job application form in a PDF, digitally sign it with you eID card (in Belgium at least) and send it to a specific email address. The PDF attachment gets picked up from the mailbox and the information is extracted and put in a database. After that a &#8220;thank you&#8221; email is sent to the applicant, while in the mean time the HR manager is notified of a new application. Upon approval by the HR manager in the so called &#8220;workspace&#8221; a new PDF is sent to the unit manager, notifying him that he should interview this candidate, together with the candidate&#8217;s résumé. After the interview the unit manager can then input his findings in a evaluation form and LiveCycle will pick that up as well to put it into the database and notify the HR manager that the evaluation has been submitted. Would the candidate be rejected, the can be marked in the &#8220;workspace&#8221; again for example, an automatic email will be sent to the candidate notifying him of his rejection.</p>
<p> Now, this is just one example of what LiveCycle can do. <strong>Even though Adobe is shifting its focus towards other strategic solutions, they will continue to develop LiveCycle (<a href="http://blogs.adobe.com/ADEP/2011/11/livecycle-business-update.html" target="_blank">as you can read here</a>), invest in finding new customers and product support is still guaranteed</strong>, so you&#8217;re not left alone with your solution if you&#8217;re currently using LiveCycle.</p>
<p><strong>As for dropping the Flash Player on mobile devices, I don&#8217;t think that is a bad thing.</strong> You see, if Adobe wants to keep the same version of the Flash Player on all devices (desktop, mobile, tablet) then a lot of code will have to go in checking whether or not things certain features are available. This requires a lot of effort and slows down progress on the features that matter the most. <strong>I mean, come on, when did you actually use a Flash based website on you mobile device?</strong> Either it wasn&#8217;t mobile optimized causing frustration in content that is not scaled properly, or it just was overkill for a mobile device.<br/><br />
Now Adobe has the opportunity to focus on the desktop platform and make full use of the GPU hardware acceleration and other cool features that require more processing power than what the other devices can offer at this moment. <strong>It is clear that Adobe wants to move in the direction of gaming with Flash</strong>, which I have been expecting for some time now.</p>
<p>Remember, I just said that the Flash Player will be dropped on mobile. <strong>That does not mean that the cross-device AIR solution is being dropped. On the contrary! AIR for mobile devices will continue to be developed by Adobe and is one of the key products/features they will maintain.</strong> So you don&#039;t have to worry about your cross-device development.</p>
<p><strong>However, the Flex SDK is going to be put into the Apache project, bringing along a new produt name as well, since Adobe won&#8217;t own the SDK anymore.</strong> Once the incubator is accepted, the product will be called &quot;Apache Flex&quot;. You can read all about the Apache Flex Incubator <a href="http://bit.ly/tpmpa7" target="_blank">right here</a>.<br/><br />
<strong>That means that from that point on the SDK will be developed and maintained by the community.</strong> That will be a good thing in the sense that probably we&#8217;ll get more features more rapidly developed. But &#8211; and there&#8217;s a big &quot;but&quot; in here &#8211; I do see a problem in the adopt of the Flex technology in big companies. You see, <strong>what companies want is a support contract with time frame commitment</strong>. They want a red phone to the help desk when they encounter serious problems and at the moment they are paying big money for that. <strong>Once Flex is owned by the community, Adobe probably won&#8217;t be doing anymore support, because it is now up to the community.</strong></p>
<p>This lack of support is what could harm Flex in the high end business companies. But then again, <strong>this will also lead to new opportunities for companies such as <a href="http://www.multimediacollege.be target="_blank">multimediacollege</a> in the sense that we can now write and publish our own training material, as well as provide support contracts for helping out companies who need assistance with some Flex problems.</strong></p>
<p>So, is Flex dead? Definitely not! And it isn&#8217;t dying either. We will have a huge community supporting the development and some highly skilled developers working on the features. I wish I had some magical device that allows me to see into the future to see what will happen with Flex when it becomes completely Open Source. But for now, I&#8217;m not yet worried about it&#8217;s future&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/12/do-flex-and-livecycle-still-have-a-future/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>My experience with putting a Flex app on the PlayBook</title>
		<link>http://www.flexpert.be/2011/05/my-experience-with-putting-a-flex-app-on-the-playbook/</link>
		<comments>http://www.flexpert.be/2011/05/my-experience-with-putting-a-flex-app-on-the-playbook/#comments</comments>
		<pubDate>Mon, 02 May 2011 11:56:37 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[BlackBerry PlayBook]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=864</guid>
		<description><![CDATA[As I&#8217;ve mentioned in my previous blog post, I&#8217;ve finally gotten hold of my free BlackBerry Playbook, so I started playing around with it. First impressions were quite good. Even my wife is interested in this device, which sounds great, but will probably mean I&#8217;ll have to kindly ask here [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve mentioned in my previous blog post, I&#8217;ve finally gotten hold of <a href="http://www.flexpert.be/2011/04/my-blackberry-playbook-has-finally-arrived/">my free BlackBerry Playbook</a>, so I started playing around with it. First impressions were quite good. Even my wife is interested in this device, which sounds great, but will probably mean I&#8217;ll have to kindly ask here to borrow it if I want to test on it&#8230;</p>
<p>But for now, she&#8217;s not getting hold of the device, because I want to try several things out. And one of those things is the real cross-device development using the Flash Platform. In my case, that means Flex of course. That&#8217;s what I&#8217;ve be doing for the past couple of days and I must say it&#8217;s really working once you get the procedure down. That&#8217;s the tricky bit for now, so let me take you through my struggles and maybe I can save you from making the same endeavors as I needed in order to get it working.</p>
<h3>Setting up the development environment</h3>
<p>This is the first part you&#8217;ll have to go through. Blackberry has issued <a href="http://us.blackberry.com/developers/tablet/adobe.jsp">a tablet OS SDK</a>, which is a plugin for Flash Builder that allows you to compile applications for the PlayBook directly from within Flash Builder. While this all sounds great, <strong>the latest releases of that plugin do not support Flex Mobile applications</strong>. That means you cannot use that SDK to compile your Flex Mobile application. You can only work with ActionScript Mobile application.</p>
<p>A second issue is the fact that the SDK is installed on top of an existing Flex 4.5 SDK and without giving away too much information, it is not compatible with all Flex 4.5 SDKs, so compiling and packaging the application from within Flash Builder is not possible with the latest versions. Hopefully BlackBerry will release another version of their SDK this is compatible soon.</p>
<p>Taking these two issues into accounad the fact that as a Flex developer I want to use a Flex Mobile project, I&#8217;ll have to package the application using the command line.</p>
<h3>Compiling and packaging the application</h3>
<p>Since the option of compiling directly for the playbook is not possible with the latest builds, I&#8217;ve used a little shortcut to get the release build of my application. I mean, if you&#8217;re working on a Flex mobile application and you compile using Flash Builder, you can only opt for the Android APK file. There is no release build that gives you the release version of the SWF file.</p>
<p>So that&#8217;s exactly what I&#8217;ve done. Then I unzipped the APK file and searched for the release version of my SWF file and used that to package my BAR file. The command to do the packaging is as follows</p>
<p><em>blackberry-airpackager -package &lt;BAR file&gt; &lt;application&gt;-app.xml &lt;application&gt;.swf blackberry-tablet.xml &lt;assets required by the application&gt;</em></p>
<h3>Signing the application</h3>
<p>Once you have the BAR file ready you have come to the trickiest part: signing the application. This is best done via command line again, but hopefully this will be included in the Flash Builder plugin once it&#8217;s updated to work with the latest builds and with Flex Mobile projects.</p>
<p>First, <strong>you need to be registered as a vendor with BlackBerry</strong> in order to obtain you code signing key. This is done only once per developer or company, depending on how you want to register yourself. Obtaining the key is done by filling out <a href="https://www.blackberry.com/SignedKeys/">this form</a>.</p>
<p>The key you receive will be a CSJ file. It all starts with that file, because now you have to <strong>register that CSJ file as well as create a keystore</strong> to communicate with the BlackBerry signing authority. So, we&#8217;ll start by setting up that keystore, which is done via the following command</p>
<p><em>blackberry-signer -csksetup -cskpass &lt;create a password&gt;</em></p>
<p>Then you need to register the CSJ file by using the following command</p>
<p><em>blackberry-signer -register -csjpin &lt;PIN&gt; -cskpass &lt;csk password from previous step&gt; &lt;CSJ file&gt;</em></p>
<p>The last thing to get you set up is to <strong>generate a coding certificate, a .p12 file</strong> that is not unlike the certificate you create for regular AIR applications. This is done by executing the following command:</p>
<p>blackberry-keytool -genkeypair -keystore &lt;certificate.p12&gt; -storepass &lt;create a password&gt; -dname &#8220;cn=&lt;company name&gt;&#8221; -alias author</p>
<p>Once you have this set up, you are all set to start signing your application. <strong>When signing an application for the BlackBerry App World you actually have to sign it twice.</strong> Once for the code signing itself and a second time to add the author data to the BAR file. This can be done by executing these two statements in this particular order.</p>
<p><em>blackberry-signer -verbose -cskpass &lt;csk password&gt; -keystore &lt;p12 certificate&gt;  -storepass &lt;certificate password&gt; &lt;application&gt;.bar RDK</em></p>
<p><em>blackberry-signer -keystore &lt;p12 certificate&gt;  -storepass &lt;certificate password&gt; &lt;application&gt;.bar author</em></p>
<p><strong>If you go through this signing process several times, make sure that you increase the application versionNumber in the &lt;application&gt;-app.xml file every single time.</strong> Otherwise you will get the error message that the application was already signed.</p>
<h3>Deploying the application on the device</h3>
<p><strong>At this point your application is ready to be submitted to the BlackBerry App World.</strong> However, you might want to install it on your own device already and not wait for approval. This can be done via command line too and it can only be done with the signed BAR file. Unsigned applications can be installed using a debug token that expires after 30 days, but the following command is not suited for that type of deployment. It will only work with signed BAR files.</p>
<p><em>blackberry-deploy &#8211; installApp -device &lt;device IP&gt; -password &lt;device password&gt; &lt;application&gt;.bar</em></p>
<p>When you execute this command the application will be installed on your BlackBerry PlayBook and you can run it as if you installed it through the App World.</p>
<p>This might not be the best way to get your Flex Mobile application on the PlayBook, but it sure has worked for me and as far as I know it is the only way to do this with my current setup of Flash Builder and PlayBook SDK.<br/><br />
If someone has a better way of doing this, please let me know as I find this not an easy process to do (what should be) a simple task</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/05/my-experience-with-putting-a-flex-app-on-the-playbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Flex themes with Flash Catalyst</title>
		<link>http://www.flexpert.be/2011/04/creating-flex-themes-with-flash-catalyst/</link>
		<comments>http://www.flexpert.be/2011/04/creating-flex-themes-with-flash-catalyst/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 09:37:52 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=803</guid>
		<description><![CDATA[In my book Flash Builder and Flash Catalyst; the new workflow I talk about different workflows for the different types of applications. These workflows are all good when creating a single application. But isn&#8217;t there something you could do for improving reusability of your design elements and collaborating more easily? [...]]]></description>
			<content:encoded><![CDATA[<p>In my book <a href="http://amzn.to/hb3RBm">Flash Builder and Flash Catalyst; the new workflow</a> I talk about different workflows for the different types of applications. These workflows are all good when creating a single application. But isn&#8217;t there something you could do for improving reusability of your design elements and collaborating more easily?</p>
<p>First thing to do, and this is what I always tend to do, is to <strong>export your Flash Catalyst components as a Flex library project</strong>. This allows you to get around the roundtripping issue, because this library project only contains Flash Catalyst generated components and will therefore remain compatible with Flash Catalyst when you need to alter the design at some point in the future.</p>
<p>Skinning your actual project is then done by linking the SWC file from the library project to your actual project and applying the proper skin to the component using the skinClass property. Now to be able to work with this properly, you&#8217;ll need to <strong>create a manifest file for that library</strong> as well. This will allow you to use only one single namespace for every component/skin in the library, even though the components/skins may reside in a number of packages.</p>
<p>Now, this approach will definitely work, but you still have to apply the <em>skinClass</em> property to every component in your application. However, <strong>you can apply all the styling on your application by defining a theme CSS that accompanies the SWC file containing the skins</strong>. Let me briefly explain this process by creating a very small example.</p>
<p>In this example I&#8217;m going to create a skin for a single component, namely the <em>HSlider</em> component. I want to make it look a little bit like the iOS slider, where you have a colored fill of the slider bar that follows the slider thumb position. To make things easier, I&#8217;m going to start out in Flash Catalyst. I simply create a new project with the default settings and I&#8217;m going to create the skin from scratch. Of course, you can certainly start out with an Illustrator or a Photoshop file. The process of creating the skin will remain exactly the same.</p>
<p>First I need to create the track and duplicate that layer to have the fill color as a separate item. Next, I&#8217;m creating the thumb for the slider by drawing two concentric circles with opposite gradients, one a little smaller than the other, to create a semi 3D lighting effect. The result looks like the image below.</p>
<p><a href="http://www.flexpert.be/wp-content/Layers-panel.png"><img src="http://www.flexpert.be/wp-content/Layers-panel-300x111.png" alt="" title="iOS Slider design" width="300" height="111" class="aligncenter size-medium wp-image-810" /></a></p>
<p>The next step is to convert that design into a working component. Now, in Flash Catalyst, unless you&#8217;re putting components on the artboard, you actually just create some skin files. So, using the Heads-Up Display (HUD) I convert the artwork into a horizontal slider. After indicating the track and thumb, my skin file is now ready to be imported into Flash Builder.</p>
<p>Since I&#8217;m going to be creating a Flex theme, I don&#8217;t just save the Flash Catalyst project and open it in Flash Builder. I&#8217;m actually going to <strong>export the library components as a Flex library project (FXPL)</strong>, as shown below. When you import the FXPL file into Flash Builder it will automatically create the library project for you.</p>
<p><a href="http://www.flexpert.be/wp-content/Library-panel.png"><img src="http://www.flexpert.be/wp-content/Library-panel.png" alt="" title="Library panel" width="284" height="236" class="aligncenter size-full wp-image-816" /></a></p>
<p>If you look at the code now, you&#8217;ll see that the size of the slider skin is fixed. But <strong>since I want to create a theme that can be used in any circumstance and in any project, I need to make a few adjustments to the generated code to make the skin more dynamic</strong>. For that I&#8217;m going to make use of the <em>[HostComponent]</em> metadata tag. This gives me a reference to the actual component that this skin is applied to. Therefore I can get the size of that component and adjust the skin accordingly. The adjusted code for the main HSlider skin looks like this.</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;s:Skin</span> xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">		xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">		width=<span style="color: #ff0000;">&quot;300&quot;</span> height=<span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>[HostComponent(&quot;spark.components.HSlider&quot;)]<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;track&quot;</span> x=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;5&quot;</span> skinClass=<span style="color: #ff0000;">&quot;components.IOSSliderTrackSkin&quot;</span> width=<span style="color: #ff0000;">&quot;{hostComponent.width}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> x=<span style="color: #ff0000;">&quot;1&quot;</span> y=<span style="color: #ff0000;">&quot;6&quot;</span> width=<span style="color: #ff0000;">&quot;{thumb.x + (thumb.width / 2)}&quot;</span> height=<span style="color: #ff0000;">&quot;6&quot;</span> radiusX=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradient</span> rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> alpha=<span style="color: #ff0000;">&quot;1.0&quot;</span> color=<span style="color: #ff0000;">&quot;#009CFF&quot;</span> ratio=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> alpha=<span style="color: #ff0000;">&quot;1.0&quot;</span> color=<span style="color: #ff0000;">&quot;#002FD1&quot;</span> ratio=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradient</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;thumb&quot;</span> x=<span style="color: #ff0000;">&quot;134&quot;</span> y=<span style="color: #ff0000;">&quot;0&quot;</span> skinClass=<span style="color: #ff0000;">&quot;components.IOSSliderThumbSkin&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Skin</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>You&#8217;ll notice that I&#8217;ve bound the colored rectangle&#8217;s size to the position of the center point of the thumb. This will assure that the colored section follows the slider thumb position instead of being static and covering the whole component.<br />
Now, the default size for the slider is 300 pixels, but if you specify another width, the component will be resized properly. I didn&#8217;t take the height into account for this simple demo, but similarly you can also adjust the height of the component according to the height specified in the application.</p>
<p><strong>Next thing to do is to create a CSS file that attaches this skin to all HSlider components.</strong> This is very simple and straightforward, as you can see in the code below.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* CSS file */</span>
<span style="color: #a1a100;">@namespace s &quot;library://ns.adobe.com/flex/spark&quot;;</span>
<span style="color: #a1a100;">@namespace fc &quot;http://ns.adobe.com/flashcatalyst/2009&quot;;</span>
&nbsp;
s|HSlider <span style="color: #00AA00;">&#123;</span>
	skinClass<span style="color: #00AA00;">:</span> ClassReference<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;components.IOSSlider&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>OK, so now our theme is ready to be used. There are a couple more steps to take before you an actually use it. First of all, you need to <strong>compile the library project</strong>, so you can link it to the actual project that you are going to apply the theme to. Since I&#8217;m using Flash Builder with automatic builds, this is already taken care of.</p>
<p>The next step is to load the CSS file into the theme selector, so you can actually apply the theme to the project using a few very simple clicks. For that, I&#8217;m going to the Design view in my project and click on the <em>Current Theme</em> link in the <em>Appearance</em> panel. This brings up the theme selector dialog.</p>
<p><a href="http://www.flexpert.be/wp-content/Import-theme.png"><img src="http://www.flexpert.be/wp-content/Import-theme-300x187.png" alt="" title="Import theme" width="300" height="187" class="aligncenter size-medium wp-image-823" /></a></p>
<p>In that dialog I&#8217;m importing the new theme by selecting the CSS file that I&#8217;ve just created and giving it a proper name. Since I&#8217;m going for an iOS look, I&#8217;ve simply named it <em>iOS</em>. Now, after the import, you can see the new theme displayed in the list of themes to choose from. So, obviously I choose that theme and click <em>OK</em>.</p>
<p><a href="http://www.flexpert.be/wp-content/Apply-theme.png"><img src="http://www.flexpert.be/wp-content/Apply-theme-300x181.png" alt="" title="Apply theme" width="300" height="181" class="aligncenter size-medium wp-image-825" /></a></p>
<p>Now that I have the new theme applied to the project, I can simply use a <em>HSlider</em> component in my application and it will automatically be styled according to the settings in the them. To prove that the theme is dynamically adjustable, I&#8217;m creating a component with a <em>width</em> property of 500 pixels.</p>
<p>If you compile the application now, you would get some errors, because the skin files cannot be found. <strong>The very last thing I need to do is to link the theme&#8217;s SWC file to my project.</strong> In this example I&#8217;ve just copied the SWC file to the <em>libs</em> folder in my project. However, you could create a RSL (Runtime Shared Library) even to have your theme deployed separately and only once for all your projects. The big advantage is that your resulting project SWF file doesn&#8217;t get affected by the theme and when you alter your theme, you can just deploy that RSL and every project that uses that theme will automatically be updated next time it is started up.</p>
<p>The result is a working slider bar that has dynamic content and is styled via a Flex theme inside of Flash Builder. Just try out the example below to see the result.</p>
<p><center>
<object width="550" height="50">
<param name="movie" value="http://www.flexpert.be/swfexamples/iOSTest.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>
<param name="allowScriptAccess" value="always"></param>
<embed wmode="transparent" type="application/x-shockwave-flash" width="550" height="50" src="http://www.flexpert.be/swfexamples/iOSTest.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/04/creating-flex-themes-with-flash-catalyst/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using your own components to convert artwork in Flash Catalyst</title>
		<link>http://www.flexpert.be/2010/10/using-your-own-components-to-convert-artwork-in-flash-catalyst/</link>
		<comments>http://www.flexpert.be/2010/10/using-your-own-components-to-convert-artwork-in-flash-catalyst/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 09:53:54 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Burrito]]></category>
		<category><![CDATA[Panini]]></category>
		<category><![CDATA[skinnable components]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=631</guid>
		<description><![CDATA[With the new versions of both Flash Builder &#8220;Burrito&#8221; and Flash Catalyst &#8220;Panini&#8221; you get a whole lot of new possibilities. Well, to be honest, these possibilities should have been included from the start, but unfortunately they weren&#8217;t. But it has to be said that the development teams are working [...]]]></description>
			<content:encoded><![CDATA[<p>With the new versions of both Flash Builder &#8220;Burrito&#8221; and Flash Catalyst &#8220;Panini&#8221; you get a whole lot of new possibilities. Well, to be honest, these possibilities should have been included from the start, but unfortunately they weren&#8217;t. But it has to be said that the development teams are working very hard on improving the products in a lot of ways.</p>
<p>One such an improvement is the fact that you can now create your own custom components with skin parts in Flash Builder and use that component in the HUD (Heads-Up Display) in Flash Catalyst. That means that you&#8217;re no longer only working from Flash Catalyst towards Flash Builder, but you can go the other way around as well. Let me show you how.</p>
<p>First, you need to <strong>create a Flash Catalyst Compatible Project</strong>, which is just another option from the <em>File &gt; New</em> menu. In the project you have to <strong>create an ActionScript Skinnable Component</strong>, which can again be found in the <em>File > New</em> menu. When you do this, make sure that you have the <em>Generate Comments</em> option checked in the popup dialog, because it will help you a lot in creating your first components.</p>
<p>In the ActionScript file, you define a couple of skin states using the [SkinState] metadata tag. In this example, we are going to create an &#8220;open&#8221; and &#8220;closed&#8221; state. Then you also need to define the skin parts. This is done by using the [SkinPart] metadata tag. Optionally you can make skin parts required by defining the metadata tag as follows: [SkinPart(required:"true")]. When we define a button, text input field and a label in the skin, the resulting file will look like this.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #3f5fbf;">/* For guidance on writing an ActionScript Skinnable Component please refer to the Flex documentation: 
	www.adobe.com/go/actionscriptskinnablecomponents */</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>Button<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>RichText<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>TextInput<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>supportClasses<span style="color: #000066; font-weight: bold;">.</span>SkinnableComponent<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
	<span style="color: #3f5fbf;">/* A component must identify the view states that its skin supports. 
	Use the [SkinState] metadata tag to define the view states in the component class. 
	[SkinState(&quot;normal&quot;)] */</span>
	<span style="color: #000000;">&#91;</span>SkinState<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;open&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>SkinState<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;closed&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyCustomComponent <span style="color: #0033ff; font-weight: bold;">extends</span> SkinnableComponent
	<span style="color: #000000;">&#123;</span>
		<span style="color: #3f5fbf;">/* To declare a skin part on a component, you use the [SkinPart] metadata. 
		[SkinPart(required=&quot;true&quot;)] */</span>
		<span style="color: #000000;">&#91;</span>SkinPart<span style="color: #000000;">&#40;</span>required=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> input<span style="color: #000066; font-weight: bold;">:</span>TextInput<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#91;</span>SkinPart<span style="color: #000000;">&#40;</span>required=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> button<span style="color: #000066; font-weight: bold;">:</span>Button<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#91;</span>SkinPart<span style="color: #000000;">&#40;</span>required=<span style="color: #990000;">&quot;false&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> label<span style="color: #000066; font-weight: bold;">:</span>RichText<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#91;</span>SkinPart<span style="color: #000000;">&#40;</span>required=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> resizeButton<span style="color: #000066; font-weight: bold;">:</span>Button<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyCustomComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">//TODO: implement function</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* Implement the getCurrentSkinState() method to set the view state of the skin class. */</span>
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> getCurrentSkinState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>getCurrentSkinState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span> 
&nbsp;
		<span style="color: #3f5fbf;">/* Implement the partAdded() method to attach event handlers to a skin part, 
		configure a skin part, or perform other actions when a skin part is added. */</span>	
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> partAdded<span style="color: #000000;">&#40;</span>partName<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> instance<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>partAdded<span style="color: #000000;">&#40;</span>partName<span style="color: #000066; font-weight: bold;">,</span> instance<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* Implement the partRemoved() method to remove the even handlers added in partAdded() */</span>
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> partRemoved<span style="color: #000000;">&#40;</span>partName<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> instance<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>partRemoved<span style="color: #000000;">&#40;</span>partName<span style="color: #000066; font-weight: bold;">,</span> instance<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Once you&#8217;ve completed the ActionScript Skinnable Component you then have to <strong>export the project</strong> by choosing <em>Project &gt; Flash Catalyst &gt; Export Flash Catalyst Project</em>. In Flash Catalyst you then have to open the FXP file to work on the project. Then you create some graphics to represent the component. You may end up with something like this.</p>
<p><img src="http://www.flexpert.be/wp-content/SkinnableComponent1.png" alt="" title="SkinnableComponent1" width="357" height="87" class="aligncenter size-full wp-image-632" /></p>
<p>The next step is where the magic happens, because when you select all of the graphics and you look in the HUD, you&#8217;ll notice that you can now <strong>convert those graphics into a Skinnable Component</strong>. This is the last option in the conversion dropdown. Once you&#8217;ve selected that option you&#8217;ll get a popup dialog which allows you to choose which component if you have more than one skinnable component available.</p>
<p><img src="http://www.flexpert.be/wp-content/SkinnableComponent2.png" alt="" title="SkinnableComponent2" width="340" height="300" class="aligncenter size-full wp-image-633" /></p>
<p>In this dialog you also have the option to load an FXPL library project in case the component you want is not yet loaded into the project. But since we&#8217;ve created the component inside of the project, we&#8217;re already having the component available. So, <strong>select that custom component and click OK</strong>. Once you&#8217;ve done that, you&#8217;ll notice that Flash Catalyst indicates that the component still needs some work, since you need to indicate all of the different skin parts you&#8217;ve defined earlier in Flash Builder.</p>
<p><img src="http://www.flexpert.be/wp-content/SkinnableComponent3.png" alt="" title="SkinnableComponent3" width="572" height="369" class="aligncenter size-full wp-image-636" /></p>
<p>Digging into the component, you&#8217;ll also notice the two skin states you&#8217;ve defined earlier on as well, which allows you to work with these different view states for your custom component. Now, <strong>assign the different skin parts and make some changes to the closed state</strong> to have two distinct states. For example, you can remove the label, resize the colored rectangle and change the label of the resize button in the closed state. Don&#8217;t forget to capture the click on the resize button to change view states at runtime.</p>
<p><img src="http://www.flexpert.be/wp-content/SkinnableComponent4.png" alt="" title="SkinnableComponent4" width="260" height="158" class="aligncenter size-full wp-image-638" /></p>
<p>As a final step, you just have to save the project and import it again in Flash Builder. You can overwrite the existing project now and when you run it, you&#8217;ll notice that the component is fully functioning now, as you can see below. Just hit the resize button to see it in action.</p>
<p><center>
<object width="400" height="100">
<param name="movie" value="http://www.flexpert.be/swfexamples/SkinnableComponents.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>
<param name="allowScriptAccess" value="always"></param>
<embed wmode="transparent" type="application/x-shockwave-flash" width="400" height="100" src="http://www.flexpert.be/swfexamples/SkinnableComponents.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2010/10/using-your-own-components-to-convert-artwork-in-flash-catalyst/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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 [...]]]></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 [...]]]></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>
<param name="allowScriptAccess" value="always"></param>
<embed wmode="transparent" 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[Actionscript 3]]></category>
		<category><![CDATA[AIR]]></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 [...]]]></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: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span><span style="color: #000066; font-weight: bold;">,</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</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><span style="color: #000066; font-weight: bold;">,</span>
       fontWeight=<span style="color: #990000;">&quot;bold&quot;</span><span style="color: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span><span style="color: #000066; font-weight: bold;">,</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span><span style="color: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span><span style="color: #000066; font-weight: bold;">,</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</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><span style="color: #000066; font-weight: bold;">,</span>
       fontWeight=<span style="color: #990000;">&quot;bold&quot;</span><span style="color: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span><span style="color: #000066; font-weight: bold;">,</span>
       <span style="color: #004993;">fontName</span>=<span style="color: #990000;">&quot;myFont&quot;</span><span style="color: #000066; font-weight: bold;">,</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> myFont<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> myFont<span style="color: #000066; font-weight: bold;">;</span>
	fontWeight<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">bold</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> myFont<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">fontStyle</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">italic</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> myFont<span style="color: #000066; font-weight: bold;">;</span>
	fontWeight<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">bold</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">fontStyle</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">italic</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> Verdana<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> Verdana<span style="color: #000066; font-weight: bold;">;</span>
	fontWeight<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">bold</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> Verdana<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">fontStyle</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">italic</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
@font<span style="color: #000066; font-weight: bold;">-</span>face <span style="color: #000000;">&#123;</span>
	src<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span>
	fontFamily<span style="color: #000066; font-weight: bold;">:</span> Verdana<span style="color: #000066; font-weight: bold;">;</span>
	fontWeight<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">bold</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">fontStyle</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">italic</span><span style="color: #000066; font-weight: bold;">;</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 [...]]]></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>

