<?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>Fuel Your Coding &#187; Flex / Flash</title>
	<atom:link href="http://fuelyourcoding.com/category/languages/flex-flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://fuelyourcoding.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Aug 2010 14:40:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introduction to Flex</title>
		<link>http://fuelyourcoding.com/introduction-to-flex/</link>
		<comments>http://fuelyourcoding.com/introduction-to-flex/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:44:13 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex / Flash]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[ria]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=306</guid>
		<description><![CDATA[As you all probably know, the RIA (Rich Internet Application) field is getting bigger with every day that goes by.
The competition between the companies is increasing with every release, preview or even sometimes just rumors about a release or a preview.
Microsoft has Silverlight, Adobe has Flash/AIR.
While I&#8217;m a Microsoft programmer (C# and MSSQL) in the web and desktop [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/introduction-to-flex/">Introduction to Flex</a></p>
]]></description>
			<content:encoded><![CDATA[<p>As you all probably know, the RIA (Rich Internet Application) field is getting bigger with every day that goes by.</p>
<p>The competition between the companies is increasing with every release, preview or even sometimes just rumors about a release or a preview.</p>
<p>Microsoft has Silverlight, Adobe has Flash/AIR.</p>
<p>While I&#8217;m a Microsoft programmer (C# and MSSQL) in the web and desktop apps, I&#8217;m definitely a fanatic Adobe fan for RIA. Enough about me, lets talk about Flex.</p>
<h2>Why Choose Flex?</h2>
<p>You are probably asking yourself the question I asked myself a few years back. I&#8217;ll tell you my reasons—you be the judge and the decision is all yours.</p>
<p>First, Flex is solid. It has a huge user base around the world writing blogs, sharing open source projects and more. The IDE is absolutely amazing and it has many features: debugging, out of the box components, graphs and more.</p>
<p>Actually, you can work with any kind of server you want, you can write a web service in Java, C#, F#, jScript, ASP, PHP, RoR and more, and Flex will consume it and learn (if you teach it) how to live with it. The final product (swf) is supported in huge percentage across browsers and operating systems.</p>
<p>Though other platforms are getting there, Flash still rules this market without a doubt.</p>
<p>Designers&#8230; like our wives, we can&#8217;t live without them. When you need to work with a designer on Flex project, he won&#8217;t need to learn a new environment. Photoshop will be just fine, and even Illustrator. Flash designers can build your entire GUI without you even writing one line of code, you can simply use the skin they create for you.</p>
<p>If you are not convinced yet, there&#8217;s nothing else I can write  to convince you. However, I&#8217;m sure you, like me,  are pretty excited about this Environment.</p>
<h2>The Beginning</h2>
<p>When Adobe introduced Flash MX to the world they created a big dilemma for developers like myself. Developers wanting to focus on the development, not wanting to mess around with graphics, vectors, shapes and more&#8230; Developers complained about the Flash IDE and still complain about it today (only today there&#8217;s an alternative), they simply did not understand the Flash messy graphics, layers, symbols and the rest. While for you Flash designers out there this seems pretty standard, that&#8217;s not the case for us developers</p>
<p>So, Adobe (as opposed to other companies) listened. Flex 1 was born on 2004, still working with ActionScript 2. In 2006 we got  Flex 2 working in AS3 and in 2008 Flex 3 arrived.</p>
<p>Flex Builder 3 is now the Official IDE for Flex/AIR apps from Adobe. Today (still in beta) there&#8217;s a newer version called FlashDeveloper CS4 (we are not going to talk about it in this article, so maybe another time, promise :-)).</p>
<p>Flex is programmed using a markup language (XML based) called MXML. Flex has specific tags used only by Flex or AIR. You can&#8217;t use those tags in Flash, never mind the version you are working with.</p>
<p>Every bit of code you write with MXML code is being &#8221;translated&#8221; behind the scenes to pure AS3 code.</p>
<h2>Screenshots of the Flex IDE</h2>
<h3>Code View</h3>
<p><span style="font-weight: normal; font-size: 13px;"><img class="alignnone size-full wp-image-312" title="Flex Code View" src="http://fuelyourcoding.com/files/6-23-2009-12-47-52-am.png" alt="Flex Code View" width="600" height="395" /></span></p>
<h3>Design View</h3>
<p><img class="alignnone size-full wp-image-313" title="Flex Design View" src="http://fuelyourcoding.com/files/6-23-2009-12-48-37-am.png" alt="Flex Design View" width="600" height="395" /></p>
<p>The environment is compatible with Windows and Mac OS X. I personally worked with it on every version of Windows (XP, Vista, Win7 32bit, Win7 64bit &#8211; told you I was a Microsoft dude).</p>
<p>Ok, that was the preview, show me the CODE!!!</p>
<h2>Show Me The M&#8230;&#8230;.XML</h2>
<p>So, we discussed that Flex requires us to use MXML to write the code. Actually the Flex Environment is pretty similar to what you know from HTML and .Net (if you are a .Net programmer).</p>
<p>The entire Flex app is usually based on something called a Canvas. The canvas is your drawing board: you place your controls on it, position them and then you start writing some code. Lets do a basic &#8220;Hello World&#8221; shall we&#8230;</p>
<p>We will start by creating a brand new project. You do so by right clicking on the blank area in the &#8220;Flex Navigator&#8221; pane (top left) and selecting the option &#8220;New&#8211;&gt;Flex Project&#8221;</p>
<p>This dialog pops up:</p>
<p><img class="alignnone size-full wp-image-314" title="New Flex Project" src="http://fuelyourcoding.com/files/6-23-2009-12-57-01-am.png" alt="New Flex Project" width="600" height="429" /></p>
<p>Select the path where you want to place your project, and just hit Next and finish selecting all the default options to the end of the dialog sequence. We do not need to &#8220;mess&#8221; with those definitions.</p>
<p>Now, you probably have the default (bluish) screen that comes out of the box in Flex. Like I mentioned, I&#8217;m not a designer so we&#8217;ll live it be for now.</p>
<p>By using drag and drop, we drag a TextInput and a Button to our canvas. We will give the TextInput an id of <code>txtUserFullName</code> and the Button the id of <code>btnSend</code>.</p>
<p>Wait, wait&#8230; what, who, where?</p>
<p><img class="alignnone size-full wp-image-308" title="Adding Controls" src="http://fuelyourcoding.com/files/6-23-2009-1-03-23-am.png" alt="Adding Controls" width="600" height="396" /></p>
<p>When placing a control on the surface you get all of it&#8217;s properties in the &#8220;Flex Properties&#8221; window (seen on the right).</p>
<p>You can also edit the code of the control by hand, just by writing your own MXML which is generated automatically for you when you drag and drop a control.</p>
<p><img class="alignnone size-full wp-image-309" title="Code Controls" src="http://fuelyourcoding.com/files/6-23-2009-1-05-49-am.png" alt="Code Controls" width="600" height="396" /></p>
<p>The fun part is coming, I promise&#8230; but first, another explanation:</p>
<p>If you are coming from AS2 this part will be totally unfamiliar to you. If you have worked in the past with Java, HTML, .Net or even PHP you should know that for a button to work, there needs to be a function &#8221;listening&#8221; to the click event on that specific button.</p>
<p>Well, Flex—as opposed to the alien language AS2—works exactly the same (At least it looks that way. It is not actually exactly the same, but for us to better understand it right now, this will do).</p>
<p>On the &#8220;Flex Properties&#8221; in the right, when selecting the button we will see there&#8217;s an &#8220;On Click&#8221; text input. This is where you should put the function name that will listen to the button click event.</p>
<p>Lets type <code>btnSend_ClichHandler()</code>. Now, let&#8217;s write this function on our &#8220;code behind.&#8221;</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot;&gt;
		&lt;mx:Script&gt;
			&lt;![CDATA[
				import mx.controls.Alert;

				private function btnSend_ClickHandler():void{
					Alert.show('Hello ' + txtUserFullName.text);
				}
			]]&gt;
		&lt;/mx:Script&gt;
		&lt;mx:Button x=&quot;10&quot; y=&quot;40&quot; label=&quot;Send&quot; id=&quot;btnSend&quot; click=&quot;btnSend_ClickHandler()&quot; /&gt;
		&lt;mx:TextInput x=&quot;10&quot; y=&quot;10&quot; id=&quot;txtUserFullName&quot; /&gt;
&lt;/mx:Application&gt;
</pre>
<p>Ok, so we are all set.</p>
<p>The final result is an SWF file (Flash) which you can load into any HTML page and it is fully compatible with all browsers and almost every operating system.</p>
<p>Let&#8217;s have a look on what happens in our browser when running our small app:</p>
<p><img class="alignnone size-full wp-image-310" title="App Running" src="http://fuelyourcoding.com/files/6-23-2009-1-19-38-am.png" alt="App Running" width="600" height="546" /></p>
<h2>Download the Flex Builder 3 Trial</h2>
<p>Flex Builder 3 isn&#8217;t free, but you can <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flexbuilder3" target="_blank">download a 60-day free trial</a> to try it out.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/introduction-to-flex/">Introduction to Flex</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/introduction-to-flex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
