<?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; Actionscript 3</title>
	<atom:link href="http://www.flexpert.be/category/actionscript-3/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>I&#8217;ll be speaking at gotoAndSki();</title>
		<link>http://www.flexpert.be/2011/10/ill-be-speaking-at-gotoandski/</link>
		<comments>http://www.flexpert.be/2011/10/ill-be-speaking-at-gotoandski/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 19:14:35 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[gotoAndSki]]></category>
		<category><![CDATA[Switzerland]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=952</guid>
		<description><![CDATA[Tonight I got one of the &#8220;coolest&#8221; emails you can get: I&#8217;ve been invited to give a session at gotoAndSki(); Switzerland on January 26th, 27th and 28th, 2012, which is really awesome. Unfortunately I haven&#8217;t been to this conference before, but I&#8217;ve heard very nice things about it and let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://switzerland.gotoandski.com"><img src="http://www.flexpert.be/wp-content/gotoAndSki.jpg" alt="" title="gotoAndSki" width="560" height="187"/></a>
<p>Tonight I got one of the &#8220;coolest&#8221; emails you can get: <strong>I&#8217;ve been invited to give a session at gotoAndSki(); Switzerland</strong> on January 26th, 27th and 28th, 2012, which is really awesome. Unfortunately I haven&#8217;t been to this conference before, but I&#8217;ve heard very nice things about it and let&#8217;s face it, skiing during the day and conferences with diner at night is not your typical conference setup. So I&#8217;m really looking forward to it.</p>
<p><strong>Now, about my session, it&#8217;s going to be titled &#8220;Database Driven Mobile Applications: the power of ORM&#8221;.</strong> Now, some of you may think &#8220;what the hell is ORM?&#8221;. Well let me reassure you that it is not magic, but it does some really magical stuff.<br/><br />
<strong>ORM allows you to create database driven applications by writing virtually no SQL statements.</strong>Normally, this type of feature is restricted to the server side of your application, but now you can use this server-side feature on the client-side in an AIR application.</p>
<p><strong>This session will talk you through the basics of using ORM in AIR and how to &#8220;automagically&#8221; synchronise your local data with a remote server.</strong> Whether that&#8217;s a PHP, Java or ColdFusion, it doesn&#8217;t matter. That&#8217;s not all: we&#8217;ll go one step further and take that ability to create database driven applications onto the mobile platform as well. Just like that!</p>
<p>If you are digging <a href="http://switzerland.gotoandski.com/sessions-speakers/">this and the other topics presented at gotoAndSki();</a> make sure you get your tickets in time to enjoy the conference and the gorgeous surroundings of the Swiss Alps. I hope to see you there: <a href="http://switzerland.gotoandski.com">switzerland.gotoandski.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/10/ill-be-speaking-at-gotoandski/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a custom required RadioButtonGroup Validator class in Flex</title>
		<link>http://www.flexpert.be/2011/07/creating-a-custom-required-radiobuttongroup-validator-class-in-flex/</link>
		<comments>http://www.flexpert.be/2011/07/creating-a-custom-required-radiobuttongroup-validator-class-in-flex/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 12:56:25 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[Validator]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=914</guid>
		<description><![CDATA[Today I was discussing the Validator classes on the Adobe prerelease forum with a couple of other Flex developers. The Flex Validator classes are pretty good for some basic validation and give you a fly-over error message (which you can customize) and a red component outline when the validation fails. [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was discussing the Validator classes on the Adobe prerelease forum with a couple of other Flex developers. <strong>The Flex <em>Validator</em> classes are pretty good for some basic validation</strong> and give you a fly-over error message (which you can customize) and a red component outline when the validation fails.</p>
<p>Now, <strong>the problem with these validators is that they are geared towards validating one single visual component</strong>, such as a <em>TextInput, TextArea, ComboBox, List</em> etc. <strong>But what about compound components</strong>, such as a <em>DateField</em> combined with a <em>TextInput</em> field for the time? Or, as I will explain in this post, a <em>RadioButtonGroup</em>, which is a non-visual component, but actually comprises the different <em>RadioButton</em> components?</p>
<p>Before I go into how I solved that problem, let me explain a bit about the Flex <em>Validator</em> class. This is the base class for all the different validators and can only check on a field being required or not. This also means that we are going to inherit from this component to create our own validator classes. Of course, <strong>you can extend other validator classes as well, but for my purpose of checking to see if a <em>RadioButton</em> in the list has been selected, the <em>Validator</em> base class will be just fine.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Validator</span> source=<span style="color: #ff0000;">&quot;{componentToCheck}&quot;</span> property=<span style="color: #ff0000;">&quot;propertyToCheck&quot;</span> </span>
<span style="color: #000000;">              trigger=<span style="color: #ff0000;">&quot;{componentToMonitor}&quot;</span> triggerEvent=<span style="color: #ff0000;">&quot;eventToMonitor&quot;</span> </span>
<span style="color: #000000;">              required=<span style="color: #ff0000;">&quot;true(default)|false&quot;</span> </span>
<span style="color: #000000;">              requiredError=<span style="color: #ff0000;">&quot;errorMessage&quot;</span><span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>As you can see in the code sample above there are a couple of important properties in the base class we have to keep in mind when developing our own validator class. First of all, the <em>componentToCheck</em> will be an instance of <em>RadioButtonGroup</em> and the <em>propertyToCheck</em> will be the <em>selection</em> property. You can use the <em>trigger</em> and <em>triggerEvent</em> properties to determine when the validation needs to take place. <strong>Leaving out the <em>trigger</em> property and explicitly setting the <em>triggerEvent</em> to an empty string will make sure that the Flex framework will never trigger the validation by itself.</strong> That means that we have to do that manually at the exact time that we want the validation to happen.</p>
<p>In the code below you can clearly see the usage of these properties in both <em>&lt;co:RadioGroupValidator/&gt;</em> instances. For all good purposes I&#8217;ve also made both a Spark and Halo form to show you the <em>RadioGroupValidator</em> works with both Spark and Halo components.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;rbgSpark&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;rbgHalo&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;co:RadioGroupValidator</span> id=<span style="color: #ff0000;">&quot;vRbgSpark&quot;</span> source=<span style="color: #ff0000;">&quot;{rbgSpark}&quot;</span> property=<span style="color: #ff0000;">&quot;selection&quot;</span> triggerEvent=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;co:RadioGroupValidator</span> id=<span style="color: #ff0000;">&quot;vRbgHalo&quot;</span> source=<span style="color: #ff0000;">&quot;{rbgHalo}&quot;</span> property=<span style="color: #ff0000;">&quot;selection&quot;</span> triggerEvent=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Form</span> defaultButton=<span style="color: #ff0000;">&quot;{btnSubmitSpark}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormHeading</span> label=<span style="color: #ff0000;">&quot;Spark form&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 1&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgSpark}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 2&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgSpark}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 3&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgSpark}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 4&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgSpark}&quot;</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;btnSubmitSpark&quot;</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;sparkSubmitHandler(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> defaultButton=<span style="color: #ff0000;">&quot;{btnSubmitHalo}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormHeading</span> label=<span style="color: #ff0000;">&quot;MX form&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 1&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgHalo}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 2&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgHalo}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 3&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgHalo}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> label=<span style="color: #ff0000;">&quot;Choice 4&quot;</span> group=<span style="color: #ff0000;">&quot;{rbgHalo}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;btnSubmitHalo&quot;</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;haloSubmitHandler(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p><strong>As for the <em>RadioGroupValidator</em> class itself</strong>, the only thing we need to do there is to override the <em>validate</em> method to see wether or not the validation succeeded. <strong>If the validation failed we need to loop over all the <em>RadioButton</em> components that belong to this group and set their errorString to the proper message</strong>, as you can see in the code below.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ValidationResultEvent</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">validators</span>.<span style="color: #006600;">Validator</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RadioGroupValidator <span style="color: #0066CC;">extends</span> Validator <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> RadioGroupValidator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		requiredFieldError = <span style="color: #ff0000;">&quot;Please choose an option from the list.&quot;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> validate<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Object</span>=<span style="color: #000000; font-weight: bold;">null</span>, suppressEvents:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:ValidationResultEvent <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> result:ValidationResultEvent = <span style="color: #0066CC;">super</span>.<span style="color: #006600;">validate</span><span style="color: #66cc66;">&#40;</span>value, suppressEvents<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">source</span>.<span style="color: #006600;">numRadioButtons</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">type</span> == ValidationResultEvent.<span style="color: #006600;">INVALID</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">source</span>.<span style="color: #006600;">getRadioButtonAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">errorString</span> = result.<span style="color: #0066CC;">message</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">source</span>.<span style="color: #006600;">getRadioButtonAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">errorString</span> = <span style="color: #000000; font-weight: bold;">null</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> result;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now, as you can see I&#8217;ve also set the <em>errorString</em> in the constructor to a specific message. This doesn&#8217;t mean that you can&#8217;t provide your own specific message anymore in the instance declaration. The reason for this is that setting a property in MXML actually uses the implicit setter method and that one is executed after the constructor has initialized the object, which means it will simply overwrite the default value.</p>
<p><center>
<object width="350" height="200">
<param name="movie" value="http://www.flexpert.be/swfexamples/RadioGroupValidator.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="350" height="200" src="http://www.flexpert.be/swfexamples/RadioGroupValidator.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</center></p>
<p><em>P.S.: If you test the forms, you will see that the Spark form doesn&#8217;t show the red error indicator as well as the MX form. Maybe that&#8217;s a glitch in the framework, maybe not. I&#8217;m still hunting that little sucker down, but no luck so far. I will update this example when I solved this problem.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/07/creating-a-custom-required-radiobuttongroup-validator-class-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Molehill&#8221; 3D Flash API is available in public beta</title>
		<link>http://www.flexpert.be/2011/02/molehill-3d-flash-api-is-available-in-public-beta/</link>
		<comments>http://www.flexpert.be/2011/02/molehill-3d-flash-api-is-available-in-public-beta/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 18:42:14 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Flash player]]></category>
		<category><![CDATA[incubator]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[molehill]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=784</guid>
		<description><![CDATA[So, now it&#8217;s finally here, the moment we&#8217;ve all been waiting for for quite some time now: Molehill has launched in a public beta version. You can download it from the brand new Incubator subsite on labs.adobe.com. Wait, what? Molehill, Incubator? What are you talking about? Allright, so you don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.flexpert.be/wp-content/MAXRacer.png" alt="" title="MAXRacer" width="250" height="138" class="alignleft size-full wp-image-785" style="margin-top:20px" />
<p>So, now it&#8217;s finally here, the moment we&#8217;ve all been waiting for for quite some time now: <strong><a href="http://labs.adobe.com/technologies/flashplatformruntimes/incubator/features/molehill.html">Molehill</a> has launched in a public beta version</strong>. You can download it from the brand new <a href="http://labs.adobe.com/technologies/flashplatformruntimes/incubator/">Incubator</a> subsite on <a href="http://labs.adobe.com">labs.adobe.com</a>. Wait, what? Molehill, Incubator? What are you talking about?</p>
<p>Allright, so you don&#8217;t know about the <a href="http://labs.adobe.com/technologies/flashplatformruntimes/incubator/features/molehill.html">Molehill</a> codename of the latest and upcoming Flash Player version? What planet have you been living on lately? But anyway, let me explain what it is. <strong>&#8220;Molehill&#8221; is the code name for a new set of low-level, GPU-accelerated 3D APIs that will enable advanced 3D experiences across screens through the Adobe Flash Platform runtimes.</strong> These new low-level APIs will provide advanced 3D and 3D engine developers the flexibility to leverage GPU hardware acceleration for significant performance gains. If you want to learn more about using these 3D APIs, you should <a href="http://blogs.adobe.com/flashplatform/2011/01/digging-more-into-the-molehill-apis.html">read up on this blog post from the Flash platform blog</a>.</p>
<p>While we have been waiting on a public beta of Molehill since MAX last year, it&#8217;s completely understandable that you haven&#8217;t heard of the Incubator site, because this is completely new. What can you expect from this subsite? The <a href="http://labs.adobe.com/technologies/flashplatformruntimes/incubator/">Incubator</a> is a new place on Adobe Labs for Adobe to share with developers features that are under development or under consideration for inclusion in future versions of the runtimes. <strong>The major difference with the beta releases is the fact that the features and capabilities of these Incubator releases may or may not make it into the final release versions.</strong></p>
<p>This is really an exiting time for 3D game developers, because now the Flash technology will enable you to create 3D games that work cross-platform with a single runtime. I sure wish I was more into games after seeing the capabilities of this Molehill release&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/02/molehill-3d-flash-api-is-available-in-public-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fiddling with Phidgets at Flash Israel</title>
		<link>http://www.flexpert.be/2011/02/fiddling-with-phidgets-at-flash-israel/</link>
		<comments>http://www.flexpert.be/2011/02/fiddling-with-phidgets-at-flash-israel/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 10:07:07 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Flash camp]]></category>
		<category><![CDATA[Flash Israel]]></category>
		<category><![CDATA[Phidgets]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=776</guid>
		<description><![CDATA[A couple of weeks ago I was lucky enough to be invited to present at Flash Israel on February 22-23. There were a lot of topics I could choose from, but looking at the list of speakers that were already selected, such as Ben Forta, Lee Brimelow, Grant Skinner, &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.flexpert.be/images/badges/FlashIsrael2011_sidebar.png" style="float:left; margin-right:10px; margin-top:10px">
<p>A couple of weeks ago I was lucky enough to be invited to present at <a href="http://www.flashisrael.com">Flash Israel</a> on February 22-23. There were a lot of topics I could choose from, but looking at the list of speakers that were already selected, such as Ben Forta, Lee Brimelow, Grant Skinner, &#8230; I knew I had to come up with something mind blowing.</p>
<p>So, after doing some soul searching I reached back to my experience with <a href="http://www.phidgets.com">Phidgets</a> and <a href="http://www.arduino.cc">Arduino</a>. Over the past year I&#8217;ve been experimenting with both and found out I love playing around with electronics. Now the great thing about these two brands is that their components can be accessed through Flash technology. </p>
<p>This is exactly what I&#8217;ll be talking about, showing some actual real-world applications as well; even using the mobile phone to control these devices. I can&#8217;t tell you exactly what I&#8217;ll be doing because that would ruin the scoop of my main demo. But I can tell you there&#8217;s a laser involved! So if you happen to be in the neighborhood of Tel Aviv, Israel next week, be sure to come over and enjoy all the awesome speakers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2011/02/fiddling-with-phidgets-at-flash-israel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding swipe gestures to you mobile Flex application</title>
		<link>http://www.flexpert.be/2010/12/adding-swipe-gestures-to-you-mobile-flex-application/</link>
		<comments>http://www.flexpert.be/2010/12/adding-swipe-gestures-to-you-mobile-flex-application/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 09:18:33 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[BlackBerry PlayBook]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Hero]]></category>
		<category><![CDATA[gesture]]></category>
		<category><![CDATA[swipe]]></category>
		<category><![CDATA[touch screen]]></category>
		<category><![CDATA[TransformGestureEvent]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=661</guid>
		<description><![CDATA[With the Flex 4.5 SDK (aka Hero) you can now create some very nifty mobile applications to run on Android enabled devices as well as on the BlackBerry PlayBook. Now, one of the features you&#8217;ll use on any touch enabled device is the swipe gesture. You can use this gesture [...]]]></description>
			<content:encoded><![CDATA[<p>With the Flex 4.5 SDK (aka Hero) you can now create some very nifty mobile applications to run on Android enabled devices as well as on the BlackBerry PlayBook. Now, one of the features you&#8217;ll use on any touch enabled device is the swipe gesture. You can use this gesture to move things around or go from screen to screen etc. But how do you implement such a feature in your Flex application?</p>
<p>Well, there are 2 options you may choose from. The first one involves using ActionScript to <strong>attach an event listener</strong>. Upon initialisation of your View component, you write the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initView<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    addEventListener<span style="color: #66cc66;">&#40;</span>TransformGestureEvent.<span style="color: #006600;">GESTURE_SWIPE</span>, onSwipe<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The good thing about this method is the fact that it is exactly the same in plain ActionScript or Flash Professional projects. The second option can only be done in Flex applications and it is actually a little bit easier to implement. In fact, you just <strong>capture the gestureSwipe event on the View tag</strong>, as shown below.

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:View</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">            xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">            gestureSwipe=<span style="color: #ff0000;">&quot;onSwipe(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>So, that&#8217;s all there is to it for capturing the swipe on a touch enabled device, such as mobile phones, tablets or even large touch screens. But you only have one single swipe event, so <strong>how do you distinguish between a swipe left and swipe right?</strong> For that, you are going to have to use the event&#8217;s properties to determine the swipe direction. and more particularly, <strong>you&#8217;ll need the offsetX property for a horizontal swipe and the offsetY property for a vertical swipe</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onSwipe<span style="color: #66cc66;">&#40;</span>event:TransformGestureEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// A swipe to the left means the offsetX property will be -1</span>
    <span style="color: #808080; font-style: italic;">// A swipe to the right means the offsetX position will be 1</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">offsetX</span> == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        doSwipeLeft<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">offsetX</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        doSwipeRight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">// The same principle applies to the vertical swipe gesture, so</span>
    <span style="color: #808080; font-style: italic;">// a swipe to the top means the offsetY position will be -1</span>
    <span style="color: #808080; font-style: italic;">// A swipe to the bottom means the offsetY position will be 1</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">offsetY</span> == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        doSwipeTop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">offsetY</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        doSwipeBottom<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2010/12/adding-swipe-gestures-to-you-mobile-flex-application/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Solving the &#8220;missing AIR application XML file&#8221; error in Flash Builder</title>
		<link>http://www.flexpert.be/2010/04/solving-the-missing-air-application-xml-file-error-in-flash-builder/</link>
		<comments>http://www.flexpert.be/2010/04/solving-the-missing-air-application-xml-file-error-in-flash-builder/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 18:27:42 +0000</pubDate>
		<dc:creator>Steven Peeters</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[app.xml]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[code-behind]]></category>

		<guid isPermaLink="false">http://www.flexpert.be/?p=440</guid>
		<description><![CDATA[When creating an AIR project, you automatically get an XML configuration file for your application, which contains the initial width and height, the available icons and the indication whether or not the application uses a custom chrome (amongst other settings). This XML file has the same name as the application [...]]]></description>
			<content:encoded><![CDATA[<p>When creating an AIR project, you automatically get an XML configuration file for your application, which contains the initial width and height, the available icons and the indication whether or not the application uses a custom chrome (amongst other settings). This XML file has the same name as the application itself, followed by &#8220;-app.xml&#8221;. OK, so now you know what exactly I&#8217;m talking about, let me explain the problem.</p>
<p>When creating AIR applications, you often create custom components, which you place in separate packages to help organize the structure of your project. And every once in a while you will also <strong>create a custom component that extends the WindowedApplication class</strong>, for example to create an application that automatically updates itself when a new version becomes available. such a component would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AutoUpdater <span style="color: #0066CC;">extends</span> WindowedApplication <span style="color: #66cc66;">&#123;</span>
&nbsp;
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> appUpdater:ApplicationUpdaterUI;
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> AutoUpdater<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    appUpdater = <span style="color: #000000; font-weight: bold;">new</span> ApplicationUpdaterUI<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    addEventListener<span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #006600;">APPLICATION_COMPLETE</span>, startAutoUpdate<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> startAutoUpdate<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    appUpdater.<span style="color: #006600;">configurationFile</span> = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;app:/updateConfig.xml&quot;</span><span style="color: #66cc66;">&#41;</span>;
    appUpdater.<span style="color: #006600;">isCheckForUpdateVisible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
    appUpdater.<span style="color: #006600;">isDownloadUpdateVisible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
    appUpdater.<span style="color: #006600;">isDownloadProgressVisible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
    appUpdater.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>UpdateEvent.<span style="color: #006600;">INITIALIZED</span>, autoUpdateInitialised<span style="color: #66cc66;">&#41;</span>;
    appUpdater.<span style="color: #006600;">initialize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> autoUpdateInitialised<span style="color: #66cc66;">&#40;</span>event:UpdateEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    appUpdater.<span style="color: #006600;">checkNow</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now, you can simply extend your new application from this AutoUpdater class by declaring it as the root tag of your main application file. However, <strong>in Flash Builder 4 this generates an error, as shown in the picture below</strong>.</p>
<p><center><a href="http://www.flexpert.be/wp-content/uploads/FBerrors.png"><img src="http://www.flexpert.be/wp-content/uploads/FBerrors.png" alt="Compilation issues in Flash Builder" title="Compilation issues in Flash Builder" style="border:0" width="600" height="154" class="aligncenter size-full wp-image-442" /></a></center></p>
<p> In this screenshot you notice there are two errors, since for my project I also created another custom class which implements the URL monitoring system as well, on top of the automatic updates. <strong>Apparently the compiler expects each application to have its own XML configuration file</strong>, even though those components are not the actual starting point for your application.</p>
<p><strong>To solve this problem you simply have to go to the project settings dialog.</strong> In that dialog you go to the &#8220;Flex Applications&#8221; part by selecting it on the left side. Within that section you can see each application within your project &#8211; yes, a single project can contain more than one applications.</p>
<p><center><a href="http://www.flexpert.be/wp-content/uploads/FBProjectSettings.png"><img src="http://www.flexpert.be/wp-content/uploads/FBProjectSettings.png" alt="Flash Builder Project Settings" title="Flash Builder Project Settings" style="border:0" width="600" height="373" class="aligncenter size-full wp-image-441" /></a></center></p>
<p>You can notice that the AutoUpdater class (and in my case the MonitoredAutoUpdater class as well) is flagged as an application. Just <strong>select that application and click the &#8220;Remove&#8221; button</strong>. This will not remove the file from the project, but instead it just removes the application flag. And because the compiler will no longer recognize it as an actual appliaction, it will not search for that XML configuration file anymore, thus solving your problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexpert.be/2010/04/solving-the-missing-air-application-xml-file-error-in-flash-builder/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>
	</channel>
</rss>

