<?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>ChikaraDev Flex/AIR Blog</title>
	<atom:link href="http://www.chikaradev.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.chikaradev.com/blog</link>
	<description>A passion for Adobe Flex / AIR.</description>
	<lastBuildDate>Wed, 09 Sep 2009 05:37:14 +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>General Flex Tutorial &#8211; Part 5 &#8211; What is ActionScript (Array, ArrayCollection)?</title>
		<link>http://www.chikaradev.com/blog/?p=256</link>
		<comments>http://www.chikaradev.com/blog/?p=256#comments</comments>
		<pubDate>Wed, 09 Sep 2009 05:34:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[ArrayCollection]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=256</guid>
		<description><![CDATA[This is the fifth in a series of posts making up a general tutorial on Adobe Flex. In this post I continue describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I discuss the Array and ArrayCollection Flex classes.
Array and ArrayCollection – arrays allow you to store [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">This is the fifth in a series of posts making up a general tutorial on Adobe Flex. In this post I continue describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I discuss the Array and ArrayCollection Flex classes.<span id="more-256"></span></p>
<p><strong>Array and ArrayCollection</strong> – arrays allow you to store multiple values in one data structure. You can create simple indexed arrays or associative arrays, known in some programming languages as hashes.</p>
<p> </p>
<p><strong>Note: the sample code in this section presents creating Arrays and ArrayCollections in ActionScript, but you can create them in MXML as well. See the Flex Builder help system for examples of creating Arrays and ArrayCollections in MXML.</strong></p>
<p> </p>
<p>You can declare an indexed array and assign it values at the same time:</p>
<pre>var clients:Array = ["Bob", "Jim", "Susan"];</pre>
<p> </p>
<p>Or you can declare the array in one statement and assign values later:</p>
<pre>var clients:Array = new Array();</pre>
<pre>…</pre>
<pre>clients[0] = "Bob";</pre>
<pre>clients[1] = "Jim";</pre>
<pre>clients[2] = "Susan";</pre>
<p> </p>
<p>Associative arrays (which are actually of the <strong>Object</strong> class, not the <strong>Array</strong> class) use “keys” instead of indexes to reference individual elements in the array:</p>
<p> </p>
<pre>var foodPrices:Object = {meat:"5.00", fish:"7.00", juice:"1.00"};</pre>
<pre>trace(foodPrices ["meat"], foodPrices ["fish"], foodPrices["juice"]);</pre>
<p> </p>
<p>You can also do this:</p>
<pre>var foodPrices:Object = new Object();</pre>
<pre>foodPrices["meat"] = "5.00";</pre>
<pre>foodPrices["fish"] = "7.00";</pre>
<pre>foodPrices["juice"] = "1.00";</pre>
<p> </p>
<p>You can also use object oriented “dot” notation to refer to associative array elements:</p>
<pre>foodPrices.meat = "5.00";</pre>
<pre>foodPrices.fish = "7.00";</pre>
<pre>foodPrices.juice = "1.00";</pre>
<p> </p>
<pre>trace(foodPrices.meat, foodPrices.fish, foodPrices.juice);</pre>
<p> </p>
<p><strong>ArrayCollection</strong> is a Flex class that wraps the Array class in order to provide additional functionality, such as the following methods not found in the Array class:</p>
<p> </p>
<p><strong>addItem(item:Object):void</strong></p>
<p>adds the item to the end of the ArrayCollection</p>
<p><strong> </strong></p>
<p><strong>addItemAt(item:Object, index:int):void</strong></p>
<p>adds the item at the specified index</p>
<p><strong> </strong></p>
<p><strong>contains(item:Object):Boolean</strong></p>
<p>returns true if the ArrayCollection contains the specified object</p>
<p><strong> </strong></p>
<p><strong>getItemAt(index:int, prefetch:int = 0):Object</strong></p>
<p>gets the item at the specified index</p>
<p><strong> </strong></p>
<p><strong>getItemIndex(item:Object):int</strong></p>
<p>returns the index of the item if it is in the ArrayCollection</p>
<p><strong> </strong></p>
<p><strong>refresh():Boolean</strong></p>
<p>applies the sort and filter to the ArrayCollection</p>
<p><strong> </strong></p>
<p><strong>removeAll():void</strong></p>
<p>remove all items from the ArrayCollection</p>
<p> </p>
<p>Sometimes you need to check to see if two objects are the same object, often inside a function. You don’t need to iterate the ArrayCollection, just do this:</p>
<p> </p>
<pre>if(myObject = myAC.getItemAt(myAC.getItemIndex(myObject))){</pre>
<pre>       Trace(“Same object.”);</pre>
<pre>}else{</pre>
<pre>       Trace(“NOT same object.”);</pre>
<pre>}</pre>
<p> </p>
<p>You can create an instance of an ArrayCollection like this:</p>
<pre>private var myAC:ArrayCollection = new ArrayCollection([</pre>
<pre>       "meat", "fish", "juice", "cheese"</pre>
<pre>]);</pre>
<p> </p>
<p>You can create an ArrayCollection of objects like this:</p>
<pre>public var foodsAC:ArrayCollection;           </pre>
<pre>public function initData():void {</pre>
<pre>       foodsAC = new ArrayCollection(</pre>
<pre>              [{food:"meat", price:"5.00"},</pre>
<pre>              {food:"juice", price:"1.00"},</pre>
<pre>              {food:"cheese", price:"2.00"}</pre>
<pre>       ]);</pre>
<pre>}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=256</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Flex Tutorial &#8211; Part 4 &#8211; What is ActionScript (classes)?</title>
		<link>http://www.chikaradev.com/blog/?p=251</link>
		<comments>http://www.chikaradev.com/blog/?p=251#comments</comments>
		<pubDate>Wed, 09 Sep 2009 05:25:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[classes]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=251</guid>
		<description><![CDATA[This is the fourth in a series of posts making up a general tutorial on Adobe Flex. In this post I continue describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I describe ActionScript classes.
Classes – ActionScript is an object oriented language making use of many object [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">This is the fourth in a series of posts making up a general tutorial on Adobe Flex. In this post I continue describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I describe ActionScript classes.<span id="more-251"></span></p>
<p><strong>Classes</strong> – ActionScript is an object oriented language making use of many object oriented constructs, such as classes, packages, inheritance, accessor methods, method overriding, etc. Classes are such a large topic that only a brief overview of the topic will be covered here.</p>
<p> </p>
<p>The following is a class we will use in our discussion of ActionScript classes.</p>
<pre>package com.chikaradev.classes {</pre>
<pre>       import mx.controls.Button; </pre>
<pre>       public class MyButton extends Button{</pre>
<pre>              private var _myvar:int = 0; </pre>
<pre>              public function MyButton(){</pre>
<pre>               super();</pre>
<pre>              }</pre>
<pre>                             </pre>
<pre>              public function set myvar(val:int):void{</pre>
<pre>               this._myvar = val;</pre>
<pre>              }</pre>
<pre> </pre>
<pre>              public function get myvar():int{</pre>
<pre>               return this._myvar;</pre>
<pre>              }</pre>
<pre>   </pre>
<pre>              override protected function updateDisplayList(unscaledWidth:Number,</pre>
<pre>               unscaledHeight:Number):void{</pre>
<pre>               super.updateDisplayList(unscaledWidth, unscaledHeight);</pre>
<pre>               this.graphics.lineStyle(3, 0xFF0000, 1);</pre>
<pre>               this.graphics.moveTo(5, this.height/2);</pre>
<pre>               this.graphics.lineTo(this.width-5, this.height/2);</pre>
<pre>               validateNow();</pre>
<pre>              }</pre>
<pre>       }</pre>
<pre>}</pre>
<p> </p>
<p><strong>package com.chikaradev.classes</strong> – it is good to organize custom classes into packages that map to the directory structure where the classes are located, relative to the main application MXML file. In this case the file for custom class <strong>MyButton</strong> reside in the following directory structure:</p>
<p>       src</p>
<p>              com</p>
<p>                     chikaradev</p>
<p>                            classes</p>
<p>                                   MyButton.as</p>
<p> </p>
<p><strong>import mx.controls.Button</strong>; &#8211; we need to import the Button class because our custom class “extends” Button, meaning it is based upon the Flex standard Button class.</p>
<p> </p>
<p><strong>public class MyButton extends Button</strong> – here we declare the custom class <strong>MyButton</strong>, with the access modifier <strong>public</strong>, using the <strong>extends</strong> keyword to indicate we are basing our class on the Flex <strong>Button</strong> class.</p>
<p> </p>
<p><strong>private var _myvar:int = 0;</strong> &#8211; our custom class will have a private variable <strong>_myvar</strong>. Often, the names of private variables in Flex start with an underscore.</p>
<p> </p>
<p><strong>public function MyButton()</strong> – this is the constructor of the class, where initialization occurs. We simply call the super() method, which calls the constructor of the “super” class, meaning the class this class extends (Button);</p>
<p> </p>
<p><strong>public function set myvar(val:int):void</strong> – Flex uses a feature called <strong>set</strong> and <strong>get</strong> methods to implement <strong>accessor</strong> methods, a key object oriented design construct. Implementing a set and get method here allows us to assign a value to <strong>_myvar</strong>, or to assess its value, using the <strong>myvar=”100”</strong> syntax in the <strong>&lt;MyButton&gt;</strong> MXML tag. The method can be named anything, but in the body we assign the parameter to the private <strong>_myvar</strong> variable:     <strong>this._myvar = val;</strong></p>
<p>  </p>
<p><strong>override protected function updateDisplayList</strong> – here we “<strong>override</strong>” the standard Flex Button class method <strong>updateDisplayList</strong>, meaning we want to change the standard behavior of the method. We first call the super class version of the updateDisplayList method, and then implement custom code, where we draw a line through the label of the button.</p>
<p> </p>
<p><strong>validateNow();</strong> &#8211; often you want to call either <strong>validateNow()</strong> or <strong>invalidateDisplayList()</strong> after custom code that affects the display list, because your code may be executed but not rendered onscreen yet, and these methods force a redraw of the UI.</p>
<p> </p>
<p>The following code illustrates defining an instance of our custom class in MXML and in ActionScript. Notice when you execute this simple application that the MyButton instance defined in MXML is displayed above the instance defined in ActionScript, because the MXML is processed before the creationComplete event is dispatched.</p>
<p> </p>
<pre>&lt;?xml version="1.0"?&gt;</pre>
<pre>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"</pre>
<pre>       creationComplete="init();" xmlns:comp="com.chikaradev.classes.*"&gt;</pre>
<pre>       &lt;mx:Script&gt;</pre>
<pre>              &lt;![CDATA[</pre>
<pre>                     import com.chikaradev.classes.MyButton;</pre>
<pre>     </pre>
<pre>                     private function init():void{</pre>
<pre>                            var mb:MyButton = new MyButton();</pre>
<pre>                            mb.label = "Greg";</pre>
<pre>                            mb.myvar = 35;</pre>
<pre>                            this.addChild(mb);</pre>
<pre>                     }</pre>
<pre>              ]]&gt;</pre>
<pre>       &lt;/mx:Script&gt;</pre>
<pre>       &lt;comp:MyButton myvar="100" label="My New Button"/&gt;</pre>
<pre>&lt;/mx:Application&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=251</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Flex Tutorial &#8211; Part 3 &#8211; What is ActionScript (variables &amp; functions)?</title>
		<link>http://www.chikaradev.com/blog/?p=244</link>
		<comments>http://www.chikaradev.com/blog/?p=244#comments</comments>
		<pubDate>Tue, 08 Sep 2009 04:30:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=244</guid>
		<description><![CDATA[This is the third in a series of posts making up a general tutorial on Adobe Flex. In this post I begin describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I cover variables and functions.
 
What is ActionScript? 
ActionScript is a scripting language based on the ECMAScript standard [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">This is the third in a series of posts making up a general tutorial on Adobe Flex. In this post I begin describing ActionScript, the programming language used to code the business logic in Flex applications. In this post I cover variables and functions.<span id="more-244"></span></p>
<p> </p>
<p><strong>What is ActionScript?</strong><strong> </strong></p>
<p>ActionScript is a scripting language based on the ECMAScript standard on which JavaScript is based. ActionScript is used to define the Model and Controller of your application. JavaScript is an interpreted language, meaning it is processed as it is executed, whereas ActionScript is a compiled language, meaning it is processed (compiled) as you are writing your application, which leads to faster execution.</p>
<p> </p>
<p>Much of your ActionScript code will consist of variables, functions, and classes, in addition to a variety of other ActionScript constructs for program control, such as conditionals, looping, etc. This section on ActionScript will provide an overview of variables, functions, classes and some of the other major programming constructs.</p>
<p> </p>
<p><strong>Variables</strong> &#8211; A variable is a named entity used to store some data, such as a number (49.99), a string (&#8221;Welcome Greg&#8221;), a Boolean value (true or false), a date (04/14/2009), etc. Variables correspond to properties and style properties in MXML.</p>
<p> </p>
<p>To use a variable, you need to declare it and assign it a value. You can declare the variable and assign an initial value later, or you can assign a value when the variable is declared. Here are some examples:</p>
<p> </p>
<pre>var validuser:Boolean;</pre>
<pre>var firstname:String = "Greg";</pre>
<pre>var myVbox:VBox = new VBox();</pre>
<pre>var currAdminPanel:AdminPanel = new AdminPanel();</pre>
<p> </p>
<p>Notice that a colon separates a variable from its &#8220;data type&#8221; (Boolean, String, AdminPanel).</p>
<p> </p>
<p>Also notice how instances of classes (VBox and AdminPanel) are created above using the &#8220;new&#8221; keyword.</p>
<p> </p>
<p>&#8220;Modifiers&#8221; can be added to variable declarations to affect aspects of the variables:</p>
<pre>private var firstname:String = "Greg";</pre>
<pre>public static var num:int;</pre>
<pre>protected const MULTIPLIER:uint = 50;</pre>
<p> </p>
<p>Each of these examples includes keywords that result in subtle variations in the qualities of the variables:</p>
<p><strong>private, public, protected, and internal</strong> specify what parts of your code can use the variable.</p>
<p><strong>var</strong> indicates the variable can change, and <strong>const</strong> indicates it is a constant, and once set cannot change.</p>
<p><strong>static</strong> specifies a variable that has one value for all instances of a class. Without the static keyword each class instance has its own instance of the variable that can have a different value.</p>
<p> </p>
<p><strong>KEY POINT: you can declare and initialize variables outside functions, but you can only use and manipulate variables within functions (discussed next). So you can declare and initialize a variable num in a single statement outside a function, but you cannot assign it a value outside a function. If you are trying to use a variable outside a function and your statement does not include the &#8220;var&#8221; keyword, there is a good chance your statement will fail.</strong></p>
<p> </p>
<p><strong>var num = 50;           </strong></p>
<p><strong>okay &#8211; declaring and assigning a variable on the same line</strong></p>
<p><strong> </strong></p>
<p><strong>var num;                    </strong></p>
<p><strong>okay &#8211; declaring a variable</strong></p>
<p><strong></strong></p>
<p><strong>num = 50;                  </strong></p>
<p><strong>error &#8211; cannot assign value to variable outside a function unless declaring it</strong></p>
<p> </p>
<p><strong>ActionScript Primitive Data Types</strong></p>
<p>Here are the ActionScript &#8220;primitive&#8221; data types. All other Flex data types are objects.</p>
<p><strong>String</strong>: a textual value, like a name or the text of a book chapter</p>
<p><strong>Boolean</strong>: a true-or-false value, such as whether a switch is on or whether two values are equal</p>
<p><strong>Numeric</strong>: ActionScript 3.0 includes three specific data types for numeric data:</p>
<p><strong>       Number</strong>: any numeric value, including values with or without a fraction</p>
<p><strong>       int</strong>: an integer (a whole number without a fraction)</p>
<p><strong>       uint</strong>: an &#8220;unsigned&#8221; integer, meaning a whole number that can&#8217;t be negative</p>
<p> </p>
<p><strong>Functions</strong> &#8211; A function is used to do something, such as add two numbers, examine a string and report on its value, calculate the time span between two dates, respond to user interaction with you application, etc.</p>
<p> </p>
<p>You define a function by specifying its &#8220;signature&#8221;. Here is a typical ActionScript function signature:</p>
<pre>private function addNumbers(num1:uint, num2:uint):uint {</pre>
<pre>       var result:uint = num1 + num2;</pre>
<pre>       return result;</pre>
<pre>}</pre>
<p> </p>
<p>Notice functions can be defined using &#8220;access modifiers&#8221; (private, public, protected) like variables to control what areas of your code can access the function.</p>
<p> </p>
<p>The important parts and keywords of the function signature are:</p>
<p><strong>function</strong> &#8211; this is what indicates this is a function, and not a variable (var) or a constant (const)</p>
<p><strong>addNumbers</strong> &#8211; this is the name of the function</p>
<p><strong>num1:uint</strong> &#8211; this is the first data parameter passed into the function for its use. num1 is the name of the parameter and uint is its data type.</p>
<p><strong>uint</strong> after the closing parenthesis and colon is the data type of the value returned to the code that called the function. If the function does not return a value, this will be <strong>void</strong>. If a return value is specified, the function must return a value, and if the return data type is void, the function cannot return a value.</p>
<p> </p>
<p>Statements that carry out the function&#8217;s work are enclosed in opening and closing curly braces <strong>{  }</strong>. Functions do not need to accept parameters between the parenthesis, and if they accept them, the function does not need to make use of them in the function body enclosed in the { }.</p>
<p> </p>
<p>The variable &#8220;result&#8221; declared within the addNumbers function above has a &#8220;scope&#8221; that is local to the function, and cannot be referenced outside the function curly braces {  }. Keywords such as access modifiers private, public, protected and internal, and also other keywords such as static, etc. cannot be used inside functions.</p>
<p> </p>
<p>The <strong>&#8230;rest</strong> parameter, allows you to pass any number or parameters, so in a function defined as <strong>myFunction(&#8230; myParams)</strong>, you refer to the parameters in the function body as array elements, myParams[0], myParams[1], myParams[3], and you can pass in any number of parameters.</p>
<p> </p>
<pre>private function myFancyFunction(... myArgs):void {</pre>
<pre>       for (var i:uint = 0; i &lt; myArgs.length; i++) {</pre>
<pre>              trace(myArgs[i]); // trace() prints data to the Flex Builder Console view</pre>
<pre>       }</pre>
<pre>}</pre>
<pre>myFancyFunction (1, "Greg", true);</pre>
<p> </p>
<p><strong>Output</strong></p>
<p>       1</p>
<p>       Greg</p>
<p>       true</p>
<p> </p>
<p>As you can see, the parameters included in the &#8230; rest parameter can be of any type, they don&#8217;t all have to be uints, Booleans, Strings, etc. The &#8230; rest parameter can be used with other parameters, but it must be the last parameter listed.</p>
<p> </p>
<pre>private function myFancyFunction(num:uint, ... myArgs):void {</pre>
<pre>       trace(num);</pre>
<pre>       for (var i:uint = 0; i &lt; myArgs.length; i++) {</pre>
<pre>              trace(myArgs[i]);</pre>
<pre>       }</pre>
<pre>}</pre>
<pre>myFancyFunction (400, 1, "Greg", true);</pre>
<p> </p>
<p><strong>Output</strong></p>
<p>       400</p>
<p>       1</p>
<p>       Greg</p>
<p>       true</p>
<p> </p>
<p>All parameters passed into functions are passed in by &#8220;reference&#8221;, except for primitive values Boolean, int, Number, String, and uint. Passing by reference means you can pass as parameters data defined outside the function, and the data outside the function will be modified if the function changes the data. Primitives are passed by &#8220;value&#8221;, and data outside is not affected by modifications inside the function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=244</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Flex Tutorial &#8211; Part 2 &#8211; What is MXML?</title>
		<link>http://www.chikaradev.com/blog/?p=235</link>
		<comments>http://www.chikaradev.com/blog/?p=235#comments</comments>
		<pubDate>Mon, 07 Sep 2009 13:54:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[general tutorials MXML]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=235</guid>
		<description><![CDATA[This is the second in a series of posts making up a general tutorial on Adobe Flex. In this post I describe MXML, the scripting language used to create the UI in Flex.
 
What is MXML?
MXML is a tag based declarative language similar to XML and HTML. Using MXML tags, you can define Flex UI controls, [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second in a series of posts making up a general tutorial on Adobe Flex. In this post I describe MXML, the scripting language used to create the UI in Flex.<span id="more-235"></span></p>
<p> </p>
<p><strong>What is MXML?</strong><strong></strong></p>
<p>MXML is a tag based declarative language similar to XML and HTML. Using MXML tags, you can define Flex UI controls, such as &lt;mx:Button&gt;, &lt;mx:ComboBox&gt;, and &lt;mx:DataGrid&gt;. You can also use MXML to define non-UI Flex components, such as &lt;mx:HTTPService&gt; to retrieve and send data, &lt;mx:NumberFormatter&gt; to format data, and &lt;mx:XML&gt;, &lt;mx:ArrayCollection&gt;, and &lt;mx:XMLListCollection&gt; to create data elements.</p>
<p> </p>
<p>Flex makes use of &#8220;properties&#8221; and &#8220;style properties&#8221; to set attributes of components. In some cases the distinction between properties and style properties is somewhat unclear, but in general properties relate to non-visual component attributes, and style properties are used to control the visual appearance of Flex UI components.</p>
<p> </p>
<p>In MXML properties and style properties are set the same way within the opening MXML tag in the format <strong>PROPERTY_NAME=&#8221;PROPERTY_VALUE&#8221;</strong>. As we will see in the section on ActionScript, properties are set in ActionScript using &#8220;dot&#8221; notation common to many object oriented programming languages (myObj.propName = propVal;), but style properties are controlled using the StyleManager setStyle(&#8221;propName&#8221;, propVal) and getStyle(&#8221;propName&#8221;) methods.</p>
<p> </p>
<p>Many times MXML tags are defined with only an opening tag:</p>
<p> </p>
<pre>&lt;mx:Label text="Enter your name:" fontSize="10"/&gt;</pre>
<p> </p>
<p>In other instances opening and closing MXML tags are used to contain other tags within them.</p>
<p> </p>
<pre>&lt;?xml version="1.0"?&gt;</pre>
<pre>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;</pre>
<pre>       &lt;mx:VBox width="400" height="300"&gt;</pre>
<pre>              &lt;mx:Button id="myBtn" label="Click Me"/&gt;</pre>
<pre>       &lt;/mx:VBox&gt;</pre>
<pre>&lt;/mx:Application&gt;</pre>
<p> </p>
<p>Starting with the top-level &lt;mx:Application&gt;, all the nested MXML tags in a Flex application make up what is known as the &#8220;<strong>display list</strong>&#8220;, a hierarchical set of &#8220;objects&#8221; making up the visual display of your application. When you define an MXML tag, the component it represents is automatically added to your application&#8217;s display list. Later we will see how adding components using ActionScript requires specifically adding the component to the display list using <strong>addChild()</strong>.</p>
<p> </p>
<p>Two types of properties deserve special mention, <strong>event</strong> properties and <strong>effect</strong> properties.</p>
<p> </p>
<p><strong>Events</strong> &#8211; some properties are used to specify a function that is called when something &#8220;significant&#8221; happens to a Flex visual or non-visual, system component. Here are some event properties that can be set for the &lt;mx:Button&gt; control:</p>
<p> </p>
<p><strong>click</strong> &#8211; the button was clicked</p>
<p><strong>hide</strong> &#8211; the &#8220;visible&#8221; property of the button was set to false</p>
<p><strong>mouseOver</strong> &#8211; user moved the mouse over the button</p>
<p> </p>
<pre>&lt;mx:Button label="Click Me" click="myClickListener(event);"</pre>
<pre>       hide="hideFunc(event);"/&gt;</pre>
<pre> </pre>
<p>As we will see later, in ActionScript event listeners are specified with the addEventHandler().</p>
<p> </p>
<p><strong>Effects</strong> &#8211; effect properties specify an effect object that should be used when some significant event occurs. Here are some examples:</p>
<p> </p>
<pre>&lt;mx:VBox hideEffect="{myFadeObj}" resizeEffect="{myResizeObj}"</pre>
<pre>       showEffect="{myFadeObj}"/&gt;</pre>
<p> </p>
<p>The id property is very important in Flex. If you wish to refer to a Flex component property when setting a property in another Flex component, the referenced component should have an id property set.</p>
<p> </p>
<pre>&lt;mx:CheckBox id="chbx" label="Ready to Go" selected="true"/&gt;</pre>
<pre>&lt;mx:Button label="Click to Go" enabled="{chbx.selected}"</pre>
<pre>    click="goNow(event)"/&gt;</pre>
<p> </p>
<p>Note: even if you wish to refer to a Flex component within that component&#8217;s tag, you still need an id. The following code will not give the desired result, setting the height of a VBox equal to the width:</p>
<p> </p>
<pre>&lt;mx:VBox width="100" height="{width}" backgroundColor="0xFFFFFF"/&gt;</pre>
<p> </p>
<p>Using the &#8220;this&#8221; keyword (used in many object oriented languages to refer to the &#8220;current object&#8221;) will not work, because &#8220;this&#8221; refers to either the root application tag or to the custom component root tag:</p>
<p> </p>
<pre>&lt;mx:VBox width="100" height="{this.width}" backgroundColor="0xFFFFFF"/&gt;</pre>
<p> </p>
<p>The above tag and the one before it without the &#8220;this&#8221; keyword will set the VBox height to the width of the application, not to the width of the VBox.</p>
<p> </p>
<p>Here is how to achieve the desired result:</p>
<pre>&lt;mx:VBox id="myVB" width="100" height="{myVB.width}"</pre>
<pre>       backgroundColor="0xFFFFFF"/&gt;</pre>
<p> </p>
<p>It is possible to code ActionScript within property values in MXML, though it is best to only do this if the ActionScript will be short. Here is an example of how to perhaps not use ActionScript in an MXML tag:</p>
<p> </p>
<pre>&lt;mx:Label fontSize="20"</pre>
<pre>       text="Your average percentage based score, graded on a curve:"/&gt;</pre>
<pre>&lt;mx:Label fontSize="20" text="{(score1+score2+score3/3)/300 * .4376}"/&gt;</pre>
<p> </p>
<p>In this case it might be better to bind the Label text to a variable defined in ActionScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=235</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Flex Tutorial &#8211; Part 1 &#8211; What is Flex?</title>
		<link>http://www.chikaradev.com/blog/?p=229</link>
		<comments>http://www.chikaradev.com/blog/?p=229#comments</comments>
		<pubDate>Sun, 06 Sep 2009 21:27:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[general tutorials]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=229</guid>
		<description><![CDATA[ This is the first in a series of posts making up a general tutorial on Adobe Flex. In this post I describe what Flex is, what RIA are, and how the MVC design pattern fits into Adobe Flex.
What is Adobe Flex?
Adobe Flex is a technology providing an environment and infrastructure for creating rich internet applications. Adobe [...]]]></description>
			<content:encoded><![CDATA[<p> This is the first in a series of posts making up a general tutorial on Adobe Flex. In this post I describe what Flex is, what RIA are, and how the MVC design pattern fits into Adobe Flex.<span id="more-229"></span></p>
<p><strong>What is Adobe Flex?</strong><strong></strong></p>
<p>Adobe Flex is a technology providing an environment and infrastructure for creating rich internet applications. Adobe Flex Builder 3 is an IDE (integrated development environment) with integrated design, coding, and debugging tools that work together to help you work more efficiently.</p>
<p> </p>
<p>When you create applications in Flex, you use primarily a combination of MXML, ActionScript, and CSS (cascading style sheets), though you could also incorporate HTML, JavaScript, and other technologies.</p>
<p> </p>
<p>One of the greatest advantages of Adobe Flex over competing technologies, such as AJAX, Microsoft Silver light, and Java FX, is that Flex applications execute in the Adobe Flash Player browser plug-in. This eliminates most of the browser inconsistencies that you need to code for in some other technologies.</p>
<p> </p>
<p><strong>What is a RIA (rich internet application)?</strong><strong></strong></p>
<p>Rich internet applications combine the richness more typically seen in desktop application user interfaces, with the low-cost development of web applications, together with engaging interactivity of multimedia communication.</p>
<p> </p>
<p>In a nutshell, RIA are applications delivered over the internet that look better than your typical web pages, are more engaging for the user, and keep the user on your web site longer per session.</p>
<p> </p>
<p>One key aspect of RIA is that unlike standard web pages where most user interaction results in a server request and complete page refresh, RIA execute more functionality on the client (end-user) browser, and only update that portion of the interface that changes due to user interaction.</p>
<p> </p>
<p><strong>Flex Applications == MXML, CSS, and ActionScript == MVC</strong><strong></strong></p>
<p>You create Flex applications with three scripting &#8220;languages&#8221;, MXML, ActionScript, and CSS (cascading style sheets). They are used to promote using the MVC (Model, View, Controller) design pattern.</p>
<p> </p>
<p><strong>Model components (ActionScript) &#8211; </strong>Encapsulates data and behaviors related to the data processed by the application. The model might represent the name, address, phone number and email address of a customer, or perhaps the contents of a shopping cart, or product descriptions and specifications.</p>
<p> </p>
<p><strong>View components (MXML and CSS) &#8211; </strong>Defines your application user interface, and the user&#8217;s view of application data. The view might contain the Form container used to enter a customer&#8217;s name, address, etc., a DataGrid control for displaying the contents of a shopping cart, or image of products in a catalog.</p>
<p> </p>
<p><strong>Controller components (ActionScript) &#8211; </strong>Handles data processing in your application. The controller provides application management and the business logic of the application. The controller does not necessarily have any knowledge of the view or the model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=229</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using HTTPService to Populate an AdvancedDataGrid</title>
		<link>http://www.chikaradev.com/blog/?p=73</link>
		<comments>http://www.chikaradev.com/blog/?p=73#comments</comments>
		<pubDate>Tue, 18 Nov 2008 07:24:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[AdvancedDataGrid]]></category>
		<category><![CDATA[HTTPService]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLListCollection]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=73</guid>
		<description><![CDATA[The Flex 3 help system has example applications showing how to load XML data into an AdvancedDataGrid when the XML is declared inline in the application MXML file, but none showing how to load XML data using HTTPService.  

The Data 
First, here is the data I used. It is in file ProductSales.xml, located in directory &#8220;data&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>The Flex 3 help system has example applications showing how to load XML data into an AdvancedDataGrid when the XML is declared inline in the application MXML file, but none showing how to load XML data using HTTPService.  <span id="more-73"></span></p>
<p><strong></strong></p>
<p><strong>The Data </strong></p>
<p>First, here is the data I used. It is in file ProductSales.xml, located in directory &#8220;data&#8221;, which is a sub-directory of the directory with the main application MXML file:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243; ?&gt;<br />
&lt;Category Category=&#8221;Poultry&#8221;&gt;<br />
    &lt;Category Category=&#8221;Chicken&#8221;&gt;<br />
        &lt;Product Product=&#8221;skinless breasts&#8221;<br />
            InStock=&#8221;565 lbs&#8221; OnOrder=&#8221;1000 lbs&#8221;/&gt;<br />
        &lt;Product Product=&#8221;thighs&#8221;<br />
            InStock=&#8221;385 lbs&#8221; OnOrder=&#8221;700 lbs&#8221;/&gt;<br />
        &lt;Product Product=&#8221;nuggets&#8221;<br />
            InStock=&#8221;230 lbs&#8221; OnOrder=&#8221;400 lbs&#8221;/&gt;<br />
    &lt;/Category&gt;<br />
    &lt;Category Category=&#8221;Turkey&#8221;&gt;<br />
        &lt;Product Product=&#8221;whole turkeys&#8221;<br />
            InStock=&#8221;1565 lbs&#8221; OnOrder=&#8221;2000 lbs&#8221;/&gt;<br />
        &lt;Product Product=&#8221;turkey burger&#8221;<br />
            InStock=&#8221;1365 lbs&#8221; OnOrder=&#8221;1200 lbs&#8221;/&gt;<br />
        &lt;Product Product=&#8221;turkey ham&#8221;<br />
            InStock=&#8221;640 lbs&#8221; OnOrder=&#8221;700 lbs&#8221;/&gt;<br />
    &lt;/Category&gt;<br />
&lt;/Category&gt;</p>
<p><strong></strong></p>
<p><strong>The Application</strong></p>
<p>Now here is the main application MXML file:</p>
<p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;mx:Application xmlns:mx=&#8221;<a href="http://www.adobe.com/2006/mxml">http://www.adobe.com/2006/mxml</a>&#8221;<br />
  creationComplete=&#8221;salesRequest.send();&#8221;&gt;<br />
  &lt;mx:Script&gt;<br />
    &lt;![CDATA[<br />
      import mx.collections.XMLListCollection;<br />
      import mx.rpc.events.ResultEvent;</p>
<p>      [Bindable] public var salesDP:XMLListCollection;<br />
           <br />
      private function salesResultHandler(event:ResultEvent):void{<br />
        salesDP = new XMLListCollection(event.result.Category);<br />
      }<br />
    ]]&gt;<br />
  &lt;/mx:Script&gt;<br />
  &lt;mx:HTTPService id=&#8221;salesRequest&#8221; useProxy=&#8221;false&#8221; resultFormat=&#8221;e4x&#8221;<br />
    result=&#8221;salesResultHandler(event)&#8221; url=&#8221;data/ProductSales.xml&#8221;/&gt;<br />
  &lt;mx:AdvancedDataGrid width=&#8221;100%&#8221; height=&#8221;100%&#8221;&gt;<br />
    &lt;mx:dataProvider&gt;<br />
      &lt;mx:HierarchicalData source=&#8221;{salesDP}&#8221;/&gt;<br />
    &lt;/mx:dataProvider&gt;<br />
    &lt;mx:columns&gt;<br />
      &lt;mx:AdvancedDataGridColumn dataField=&#8221;@Category&#8221;<br />
        headerText=&#8221;Category&#8221;/&gt;<br />
      &lt;mx:AdvancedDataGridColumn dataField=&#8221;@Product&#8221;<br />
        headerText=&#8221;Product&#8221;/&gt;<br />
      &lt;mx:AdvancedDataGridColumn dataField=&#8221;@InStock&#8221;<br />
        headerText=&#8221;In Stock&#8221;/&gt;<br />
      &lt;mx:AdvancedDataGridColumn dataField=&#8221;@OnOrder&#8221;<br />
        headerText=&#8221;On Order&#8221;/&gt;<br />
    &lt;/mx:columns&gt;<br />
  &lt;/mx:AdvancedDataGrid&gt;   <br />
&lt;/mx:Application&gt;</p>
<p><strong></strong></p>
<p><strong>What&#8217;s Going On</strong> </p>
<p>Let&#8217;s go through the application to see what&#8217;s going on.</p>
<p><strong></strong></p>
<p><strong>Import Classes and Create an XMLListCollection Variable</strong></p>
<p> import mx.collections.XMLListCollection;<br />
 import mx.rpc.events.ResultEvent;</p>
<p> [Bindable] public var salesDP:XMLListCollection;</p>
<p><strong></strong></p>
<p><strong>Add an HTTPService Component to Load the Data</strong></p>
<p>&lt;mx:HTTPService id=&#8221;salesRequest&#8221; useProxy=&#8221;false&#8221; resultFormat=&#8221;e4x&#8221;<br />
  result=&#8221;salesResultHandler(event)&#8221; url=&#8221;data/ProductSales.xml&#8221;/&gt;</p>
<p><strong></strong></p>
<p><strong>Add the AdvancedDataGrid</strong></p>
<p>&lt;mx:AdvancedDataGrid width=&#8221;100%&#8221; height=&#8221;100%&#8221;&gt;<br />
  &lt;mx:dataProvider&gt;<br />
    &lt;mx:HierarchicalData source=&#8221;{salesDP}&#8221;/&gt;<br />
  &lt;/mx:dataProvider&gt;<br />
  &lt;mx:columns&gt;<br />
    &lt;mx:AdvancedDataGridColumn dataField=&#8221;@Category&#8221; <br />
      headerText=&#8221;Category&#8221;/&gt;<br />
    &lt;mx:AdvancedDataGridColumn dataField=&#8221;@Product&#8221;<br />
      headerText=&#8221;Product&#8221;/&gt;<br />
    &lt;mx:AdvancedDataGridColumn dataField=&#8221;@InStock&#8221; <br />
      headerText=&#8221;In Stock&#8221;/&gt;<br />
    &lt;mx:AdvancedDataGridColumn dataField=&#8221;@OnOrder&#8221; <br />
      headerText=&#8221;On Order&#8221;/&gt;<br />
  &lt;/mx:columns&gt;<br />
&lt;/mx:AdvancedDataGrid&gt;   </p>
<p><strong></strong></p>
<p><strong>Don&#8217;t Forget to Call the HTTPService send() Method</strong></p>
<p>&lt;mx:Application xmlns:mx=&#8221;<a href="http://www.adobe.com/2006/mxml">http://www.adobe.com/2006/mxml</a>&#8221;<br />
  creationComplete=&#8221;salesRequest.send();&#8221;&gt;</p>
<p> </p>
<p>You can see the running app here (right-click to view source):</p>
<p><a title="ADG_XML_HTTPService" href="http://www.chikaradev.com/flex/apps/ADG_XML_HTTPService/index.html" target="_blank">ADG_XML_HTTPService</a>  </p>
<p>Hope this helps. Thanks for stopping by, and see you in the <a title="Adobe Flex Forums" href="http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=60&amp;catid=585" target="_blank">Adobe Flex Forums</a>!</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=73</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Localized Framework Resource Bundle Files</title>
		<link>http://www.chikaradev.com/blog/?p=17</link>
		<comments>http://www.chikaradev.com/blog/?p=17#comments</comments>
		<pubDate>Sat, 01 Nov 2008 05:47:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[localize]]></category>
		<category><![CDATA[resource]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=17</guid>
		<description><![CDATA[While in the Adobe Flex Forums, one of my favorite places to visit each day, someone asked how to localize the names of the days in the DateChooser control. The key lies in building the framework resource bundle files for your target language.
Setup a New Flex Project
To show how this is done, I&#8217;ll first create [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp mceIEcenter" style="TEXT-ALIGN: left">While in the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a>, one of my favorite places to visit each day, someone asked how to localize the names of the days in the DateChooser control. The key lies in building the framework resource bundle files for your target language.<span id="more-17"></span></div>
<p><strong>Setup a New Flex Project</strong></p>
<p style="text-align: left;">To show how this is done, I&#8217;ll first create a new Flex project named <strong>LocalizationFrameworkResources</strong>. I&#8217;ll assume you know how to do that. If not, see this topic in the FlexBuilder help system or LiveDocs:</p>
<p><span><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=projects_3.html" target="_blank">Creating a <span class="resultofText">Flex</span><span> <span class="resultofText">project</span> with no server</span></a></span></p>
<p><span><strong>Adding a DateChooser Control</strong></span></p>
<p style="text-align: left;">Now that the project has been created, add a DateChooser control.  You can do this in design mode or source mode. This is how your project should appear in source mode.</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221;&gt;<br />
    &lt;mx:DateChooser/&gt;<br />
&lt;/mx:Application&gt;</p>
<p style="text-align: left;">This is how the Flex application should appear if you launch it.</p>
<div id="attachment_34" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.chikaradev.com/blog/wp-content/uploads/2008/10/localizationframeworkresources_en_us.jpg"><img class="size-full wp-image-34" title="localizationframeworkresources_en_us" src="http://www.chikaradev.com/blog/wp-content/uploads/2008/10/localizationframeworkresources_en_us.jpg" alt="Flex Application with DateChooser Control" width="500" height="518" /></a><p class="wp-caption-text">Flex Application with DateChooser Control</p></div>
<p><span><strong>Framework Resource Bundle Files</strong></span></p>
<p style="text-align: left;"><span><span>As seen in the screen shot above, the DateChooser control is currently displaying month names and abbreviations for the days of the week in English. While the custom strings that make up most of the UI of your Flex application are localized by putting the custom strings in .properties files, accessed through resource bundles, strings found in controls like the DateChooser are located in Flex framework .properties files, accessed internally via framework resource bundles. This blog post is all about localizing the framework resource bundle files.</span></span></p>
<div><span><span><span><strong>Change the Locale to French (fr_FR)</strong></span></span></span><span><span> </span></span></div>
<p style="text-align: left;"><span>We&#8217;re going to localize for French, so we need to change the locale of the project to fr_FR. This will cause the compiler to look for French framework resource bundle SWC files.</span></p>
<p style="text-align: left;"><span>Open the main app file <strong>LocalizationFrameworkResources.mxml</strong>, and then select <strong>Project &#8211; Properties</strong> in the FlexBuilder menu. In the dialog box that launches, click on the <strong>Flex Compiler </strong>property category on the left, and then in the <strong>Additional compiler arguments</strong> text input change the default locale from en_US to fr_FR. The text input should now read <strong>-locale fr_FR</strong>, as seen in the following screen shot.</span></p>
<div id="attachment_29" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.chikaradev.com/blog/wp-content/uploads/2008/10/changelocale.jpg"><img class="size-full wp-image-29" title="changelocale" src="http://www.chikaradev.com/blog/wp-content/uploads/2008/10/changelocale.jpg" alt="Changing the Project Properties - Locale Compiler Argument" width="500" height="473" /></a><p class="wp-caption-text">Changing the Project Properties - Locale Compiler Argument</p></div>
<p><strong>Now We Have a Compile Error</strong></p>
<p style="text-align: left;">When you close the project properties dialog box, if you have the &#8220;<strong>Build Automatically</strong>&#8221; setting checked in the <strong>Project</strong> menu, the project should immediately attempt to compile, and you should get an error similar to the following:</p>
<p>unable to open &#8216;C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks\locale\fr_FR&#8217;</p>
<p>This error occurs because we have changed the project locale but the French framework resources do not yet exist. Don&#8217;t get me started on the topic of why Adobe does not ship FlexBuilder and the Flex SDK with localized framework resources for some of the locales developers are most likely to create applications for, such as Japanese, French, German, Spanish, etc.</p>
<p><strong>Copy the English Framework Resource Files</strong></p>
<p>First we need to make a copy of the English resource .properties files, which we will localize and then build into a SWC file. The English resources are located here:</p>
<p style="text-align: left;">INSTALL_DIR\Flex Builder 3\sdks\3.1.0\frameworks\projects\framework\bundles\en_US\src</p>
<p>Just create a copy of the entire en_US directory and rename it to fr_FR, so you now have this directory:</p>
<p style="text-align: left;">INSTALL_DIR\Flex Builder 3\sdks\3.1.0\frameworks\projects\framework\bundles\fr_FR\src</p>
<p><strong>Localize the .properties Files</strong></p>
<p>In order to localize the date related strings in the DateChooser control, we need to localize some strings in two of the framework resource .properties files, <strong>controls.properties</strong> and <strong>SharedResources.properties</strong>.</p>
<p>Open these two files in your favorite text editor and change the following strings as indicated (we&#8217;re only changing strings absolutely necessary for our example app):</p>
<p><strong>controls.properties</strong></p>
<p>Before:</p>
<p>dayNamesShortest=S,M,T,W,T,F,S</p>
<p>firstDayOfWeek=0<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>After:</p>
<p>dayNamesShortest=D,L,M,M,J,V,S</p>
<p>firstDayOfWeek=1 (first day of the week is Monday, well, actually Lundi)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><strong>SharedResources.properties</strong></p>
<p>Before:</p>
<p style="text-align: left;">monthNames=January, February, March, April, May, June, July, August, September, October, November, December</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>After:</p>
<p style="text-align: left;">monthNames=janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre</p>
<p>After making these changes save the files, and ensure the files are saved in UTF-8 encoding, otherwise the high-ascii characters will not display properly (they display as rectangles). If you were localizing into Japanese, Russian, etc. those characters would also not display correctly. The files can be saved with or without the UTF-8 <a href="http://en.wikipedia.org/wiki/Byte_order_mark" target="_blank">BOM (byte order mark)</a>. It is always better to have the BOM, just in case you need to check for it, though in this program you will not need to check for the BOM.</p>
<p><strong>Build SWC Files from the Localized Framework Resource .properties Files</strong></p>
<p>Now the .properties files must be compiled into SWC files. Open a CMD window and change the directory to this path (or the equivalent on your machine):</p>
<p style="text-align: left;">INSTALL_DIR\Flex Builder 3\sdks\3.1.0</p>
<p>Now execute this on the command line:</p>
<p>bin\compc -locale=fr_FR -source-path+=frameworks/projects/framework/bundles/fr_FR/src -include-resource-bundles=collections,containers,controls,core,effects,formatters,logging,SharedResources,skins,states,styles,utils,validators -output=frameworks/locale/fr_FR/framework_rb.swc</p>
<p>as seen in the value of the compile argument -output, the output file is here:</p>
<p style="text-align: left;">INSTALL_DIR\Flex Builder 3\sdks\3.1.0\frameworks\locale\fr_FR\framework_rb.swc</p>
<p>Note: this directory must already exist of the compile will fail, so just create an empty directory:</p>
<p style="text-align: left;">INSTALL_DIR\Flex Builder 3\sdks\3.1.0\frameworks\locale\fr_FR</p>
<p><strong>Recompile and Relaunch</strong></p>
<p>Force a recompile of the application by typing a space in the mxml file and then deleting the space and saving (if Project &#8211; Build Automatically is checked in the menu), then relaunch and you should see the month of December (décembre in French) display as follows:</p>
<div id="attachment_50" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.chikaradev.com/blog/wp-content/uploads/2008/11/localizationframeworkresources_fr_fr.jpg"><img class="size-full wp-image-50" title="localizationframeworkresources_fr_fr" src="http://www.chikaradev.com/blog/wp-content/uploads/2008/11/localizationframeworkresources_fr_fr.jpg" alt="French App" width="500" height="518" /></a><p class="wp-caption-text">French App</p></div>
<p>Also notice that the abbreviations for the days of the week are localized.</p>
<p><strong>In Conclusion</strong></p>
<p>That&#8217;s it, you have now localized some strings in the Flex framework resource files. You might want to save the .properties files as ANSI format instead of UTF-8, recompile and relaunch the application, to see what happens. You&#8217;ll be better prepared to know what to do to correct the situation if you see it first-hand. Here is an example:</p>
<div id="attachment_53" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.chikaradev.com/blog/wp-content/uploads/2008/11/localizationframeworkresources_fr_fr_badchars.jpg"><img class="size-full wp-image-53" title="localizationframeworkresources_fr_fr_badchars" src="http://www.chikaradev.com/blog/wp-content/uploads/2008/11/localizationframeworkresources_fr_fr_badchars.jpg" alt="French App - Corrupt Characters" width="500" height="518" /></a><p class="wp-caption-text">French App - Corrupt Characters</p></div>
<p>Here is the completed application on ChikaraDev, right-click to view the source code:</p>
<p><a href="http://www.chikaradev.com/flex/apps/LocalizationFrameworkResources/" target="_blank">LocalizationFrameworkResources</a></p>
<p>Thanks for stopping by the <a href="http://www.chikaradev.com" target="_blank">ChikaraDev</a> blog. Come again soon!</p>
<p>Take care, and see you in the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a>,</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Flex 3 with AIR Certification Exam Now Out !!!</title>
		<link>http://www.chikaradev.com/blog/?p=13</link>
		<comments>http://www.chikaradev.com/blog/?p=13#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:47:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[exam]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=13</guid>
		<description><![CDATA[The Adobe Flex 3 with AIR certification exam is now out, and Adobe just released the study guide as well.
The Adobe Flex certification site is not updated as of this date, but the study guide is here: Adobe Flex 3 with AIR Study Guide.
One difference in the Adobe Flex 3 with AIR exam is that, as its [...]]]></description>
			<content:encoded><![CDATA[<p>The Adobe Flex 3 with AIR certification exam is now out, and Adobe just released the study guide as well.</p>
<p>The Adobe Flex certification site is not updated as of this date, but the study guide is here: <a href="http://partners.adobe.com/public/en/ace/ACE_Exam_Guide_FlexAIR.pdf" target="_blank">Adobe Flex 3 with AIR Study Guide</a>.<span id="more-13"></span></p>
<p>One difference in the Adobe Flex 3 with AIR exam is that, as its name implies, it covers not just Flex 3, but also AIR. One impact is that those of us who are Adobe Flex 2 ACE certified will have to take the full exam again. With most Adobe product certifications, you take a scaled down &#8220;re-certification&#8221; exam on the new features in the latest release. Because this new exam covers AIR, we all need to take the full exam.</p>
<p>This is slightly unfortunate, but in the end we will gain greater expertise in AIR, which is a good thing.</p>
<p>I thought I would share some notes on how I prepared for the Flex 2 Adobe Certified Expert (ACE) exam, which I passed in April with a score of 77% (minimum passing score was 73%).</p>
<p>I studied pretty hard for this exam, though I was weak on Flex Data Services. My strength in other areas saved me.</p>
<p><strong>Section Name &#8211; Percent Correct</strong></p>
<p>Flex Application User Interface (UI) Creation &#8211; <strong>93% correct</strong></p>
<p>Flex System Architecture and Design &#8211; <strong>92% correct</strong></p>
<p>Flex Application Programming Fundamentals &#8211; <strong>75% correct</strong></p>
<p>Interacting with Remote Data and Flex Applications &#8211; <strong>46% correct</strong></p>
<p>I thought the exam was tough! I had doubts I would pass, but I said a prayer at the end, maybe that helped. I went through most of the Flex 2 developers guide twice, and created 450 4 x 6 flashcards, with about 1200 total questions. I created the flash cards going through the developers guide a third time, but that time not compiling the sample questions, just looking for data that might not be firmly stuck in my brain.</p>
<p>Time to study up for the Flex 3 / AIR exam!</p>
<p><a href="http://www.adobe.com/devnet/flex/articles/flex_certification.html" target="_blank">Adobe Flex Certification Page</a></p>
<p><a href="http://www.vue.com/" target="_blank">Pearson VUE (certification testing site)</a></p>
<p>Take care, and see you in the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a>,</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Mask for Simulated Movement in Form Navigation</title>
		<link>http://www.chikaradev.com/blog/?p=10</link>
		<comments>http://www.chikaradev.com/blog/?p=10#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:36:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Insuricorp]]></category>
		<category><![CDATA[mask]]></category>
		<category><![CDATA[movement]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=10</guid>
		<description><![CDATA[I just completed some initial investigation for someone wanting to achieve the effect of a &#8220;moving&#8221; bar for form navigation, as seen in this Flex DevNet article (see Figure 7a): Designing for Flex – Part 6: Guiding with motion.
A quick Google for &#8220;Insuricorp&#8221; revealed that Adobe seems to maintain this mockup in which the effect [...]]]></description>
			<content:encoded><![CDATA[<p>I just completed some initial investigation for someone wanting to achieve the effect of a &#8220;moving&#8221; bar for form navigation, as seen in this Flex DevNet article (see Figure 7a): <a href="http://www.adobe.com/devnet/flex/articles/fig_pt6_05.html" target="_blank">Designing for Flex – Part 6: Guiding with motion</a>.<span id="more-10"></span></p>
<p>A quick Google for &#8220;Insuricorp&#8221; revealed that Adobe seems to maintain this mockup in which the effect is more clearly seen:  <a href="http://pedemo.adobe.com/websites/insuricorp/" target="_blank">Insuricorp</a></p>
<p>You can login with user JohnJacobs, password password and click on the &#8220;Report a Claim&#8221; tab to see the movement more clearly.</p>
<p>The demo seems a little buggy, typing in the password doesn&#8217;t always take, so I had to delete the password and retype, but its a good way to get a more clear idea of the motion. And if you navigate away from the &#8220;Report a Claim&#8221; tab you may have to logout and log back in.</p>
<p><strong>An Initial Stab at a Solution</strong></p>
<p>I initially achieved this effect to some degree. At the end of this blog post I will offer acknowledgements as to shortcomings in how I did this, ideas for improvement (the subject of a future blog post), and TODO work to attempt to come closer to the actual desired effect.</p>
<p>Here is my implementation of the &#8220;<a href="http://www.chikaradev.com/flex/apps/SlidingFormBar/index.html" target="_blank">Sliding Form Bar</a>&#8221; app:</p>
<p>Right-click and select View Source from the context menu to see the source code, images, etc.</p>
<p><strong>Three Images, One Mask, One clickHandler, and Six States (including base state)</strong></p>
<p>My solution was to create three images of identical size in Adobe Illustrator that serve as the 5 &#8220;buttons&#8221; allowing the user to navigate the form. One image has black text and a white gradient background, one has white text and a burgundy gradient background, and one is just blue. The blue image will serve as the mask and is not seen, so the color does not matter.</p>
<p>The 3 Image controls are in a Canvas, with the &#8220;white&#8221; image first, then the mask image, and last the &#8220;burgundy&#8221; image. The mask image will effective cover the &#8220;white&#8221; image, and moving it to the left or right will reveal part of the &#8221;burgundy&#8221; image underneath.</p>
<p>The white&#8221; and &#8221;burgundy&#8221; images share a common clickHandler method used to determine where the user clicked (over which of the 5 &#8220;buttons&#8221;). The event object localX and localY properties tell us this. Depending on where the user clicked on the image, the current state is set to one of five states. The only thing the states do is change the x coordinate of the mask image.</p>
<p><strong>Admissions of Laziness, Fatigue, and TODO</strong></p>
<p>My implementation did not fully achieve the effect the person I performed this investigation for was after, but it is a start. I plan to pursue this further (future blog post), but feel free to save me some time and give me the best solution!</p>
<p>I have a slight cold now, it&#8217;s after mid-night, so I should get to sleep. Also, I just turned 48 years old and so I just started a &#8220;200 in 24&#8243; attempt to achieve a life-long dream of being able to bench press 200 pounds ten times by the time I am fifty, and tomorrow is a workout day.</p>
<p>I have a Flex app &#8220;WorkoutMaster&#8221; in the works so you&#8217;ll be able to monitor my progress over the next 24 months.</p>
<p>But I digress (again)&#8230;</p>
<p>You could probably just use 5 images, one for each &#8220;button&#8221;, and forgo all the localX and localY stuff, just have a separate click handler for each button image selecting the right state. Who knows, you might be able to use an image map. I&#8217;ve never done that in Flex and I don&#8217;t know if it is possible.</p>
<p>It probably is best to use &#8220;Move&#8221; effects to get the &#8220;easing&#8221; motion. I&#8217;ll try that next time I look at this. I think I could have eliminated one of the states by referring to the base state instead. I&#8217;ll try that.</p>
<p>The hardest part I can think of is achieving the &#8220;barber shop&#8221; moving diagonal stripe in the Insuricorp example. Any suggestions?</p>
<p>That&#8217;s it for now. Thanks, and good night, er&#8230; morning.</p>
<p>Take care, and see you in the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a>,</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex vs Silverlight &#8211; A Vote for Flex</title>
		<link>http://www.chikaradev.com/blog/?p=8</link>
		<comments>http://www.chikaradev.com/blog/?p=8#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:19:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.chikaradev.com/blog/?p=8</guid>
		<description><![CDATA[I saw this posting in the Adobe Flex Forums today from someone who checked out Silverlight for six months and then checked out Flex and comments on how much easier it is to learn Flex: Flex is the way to go &#8211; Comparison to Silverlight.
I got Flex 2 certified (ACE) in April of this year, and [...]]]></description>
			<content:encoded><![CDATA[<p>I saw this posting in the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a> today from someone who checked out Silverlight for six months and then checked out Flex and comments on how much easier it is to learn Flex: <a href="http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&amp;catid=585&amp;threadid=1402466&amp;enterthread=y" target="_blank">Flex is the way to go &#8211; Comparison to Silverlight</a>.<span id="more-8"></span></p>
<p>I got Flex 2 certified (ACE) in April of this year, and as soon as I get Flex 3 certified in the next couple of months I was going to check out Silverlight.</p>
<p>The only reason I was going to check it out is because I feel that having become somewhat competent in Flex I may be in a good position to comment on Silverlight now.</p>
<p>Looks like I may have a tough time. Great post, and its great to see that Flex stands a chance against Silverlight. I&#8217;m certainly banking on Flex / AIR becoming hugely popular in the future. My gut tells me it is the technology to study right now. Hope I&#8217;m right.</p>
<p>Take care, and see you on the <a href="http://www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60" target="_blank">Adobe Flex Forums</a>.</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chikaradev.com/blog/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
