<?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>Coding Color</title>
	<atom:link href="http://www.codingcolor.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingcolor.com</link>
	<description>is Manuel Gonzalez</description>
	<lastBuildDate>Wed, 25 May 2011 06:53:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Quartz Composer and Arduino</title>
		<link>http://www.codingcolor.com/microcontrollers/quartz-composer-and-arduino/</link>
		<comments>http://www.codingcolor.com/microcontrollers/quartz-composer-and-arduino/#comments</comments>
		<pubDate>Wed, 25 May 2011 06:33:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Micro Controllers]]></category>
		<category><![CDATA[Arduino Pro Mini]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[Potentiometer]]></category>
		<category><![CDATA[Quartz]]></category>
		<category><![CDATA[Quartz Serial input]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=3725</guid>
		<description><![CDATA[Quartz Composer is a graphics development environment that gives you access to the graphics stack of Mac OS X. Quartz uses a Visual Programming paradigm which enables you to combine the capabilities of Cocoa, Quartz 2D, Core Image, OpenGL, and QuickTime. You can create Image filters, screen savers, data-driven visual effects, live performance animations and [...]]]></description>
			<content:encoded><![CDATA[<p>Quartz Composer is a graphics development environment that gives you access to the graphics stack of Mac OS X. Quartz uses a Visual Programming paradigm which enables you to combine the capabilities of Cocoa, Quartz 2D, Core Image, OpenGL, and QuickTime. You can create Image filters, screen savers, data-driven visual effects,  live performance animations and custom user-interface widgets. </p>
<p>The Visual programing paradigm easily allows you to create prototypes by manipulating graphical API elements on the system rather than by specifying them textually as in traditional programming languages.  These system API elements are referred to as patches and are connected to create a composition. As you work with a composition, you can visually see the results in a viewer window, no compilation required.</p>
<p>The following is a really simple Quartz example utilizing an Arduino Micro-Controller as an input. We will be connecting a pot (potentiometer ) to the Arduino and measuring the amount of voltage resistance as an analog value. The Arduino will convert the value to a number between 0 and 1023 and it will print the number to the serial port . We will set up Quartz to monitor the serial port and to display the incoming value in its viewer.</p>
<p><strong>REQUIRED HARDWARE :</strong></p>
<li>Arduino Board</li>
<li>10-kilohm Potentiometer </li>
<li> Jumper wire</li>
<p><strong>REQUIRED SOFTWARE :</strong></p>
<li>Arduino IDE</li>
<li>Quartz Composer</li>
<li>Kineme Serial IO patch</li>
<p>I&#8217;m going to assume you are familiar with the Arduino board and you have already installed the Arduino Ide on your computer. If not, here&#8217;s a <a href="http://arduino.cc/en/Guide/MacOSX"><u>basic tutorial</u></a> to get you up and running. I will walk you through the necessary steps to connect Quartz Composer to the Arduino. </p>
<p>Let&#8217;s start off by identifying your <a href="http://www.apple.com/support/mobileme/en/os_version.html"><u>operating system version</u></a>, and determine if your Mac&#8217;s graphics card supports Quartz Extreme or Core Image.</p>
<p><em>*NOTE : If you use Mac OS X v10.6, your Mac already meets the requirements for Quartz Extreme and Core Image graphics.</em></p>
<p>The following steps will help you identify your graphics card support for Quartz Extreme or Core Image.</p>
<p>(1) Open System Profiler (in /Applications/Utilities).<br />
(2) Click &#8220;Graphics/Displays&#8221; under Contents.<br />
(3) In the right pane under &#8220;Display,&#8221; look for the Quartz Extreme and Core Image lines; next to each, you will see either<br />
     &#8220;Supported&#8221; or &#8220;Not Supported.&#8221;</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/system_profiler.jpg" alt="" title="system_profiler" width="518" height="481" class="aligncenter size-full wp-image-3736" /></p>
<p>Computers that have a Core Image capable graphics card will sometime display &#8220;Hardware Accelerated&#8221; and those that do not will have software written in system profiler like so: &#8220;Software (Titanium PowerBook G4) &#8221;</p>
<p>As you can see my Macbook Pro has the muscles needed to continue on to the next step of installing Apple&#8217;s Xcode suite of tools. If you haven&#8217;t already registered as an <a href="http://developer.apple.com/"><u>Apple Developer</u></a>, <em>(all the cool kids are doing it)</em> this is the perfect opportunity to do so. The main reason to register is to be able to access the downloads section of the Developer Tools and of course to get support from Apple if ever needed. You don&#8217;t have to join the paid program, choose the FREE option. </p>
<p>Here&#8217;s the direct link to the <a href="http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.3.3.3.1"><u>Apple Developer tools section</u></a><em> (you must be logged in to Apple Support to access the page)</em>. Peruse the list, download and install a compatible version of Xcode for your current operating system. </p>
<p>Once you have installed Xcode, you now have access to the Quartz Composer application. Quartz Composer is located under:</p>
<p><strong>/Developer/Applications </strong><br />
<em>(not in the standard/Applications directory)</em></p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-14.png" alt="Quartz Composer file location" title="Quartz Composer location" width="739" height="435" class="aligncenter size-full wp-image-3782" /><br />
Select the Quartz Composer.app icon and drag it to your dock for easier access. The next thing you need to do is register with <a href="http://kineme.net/"><u>Kineme</u></a> to have access to their media patches. The patch we are most interested in is the <a href="http://kineme.net/release/SerialIO/200912060.2"><u>Kineme Serial IO plugin</u></a> <em>(you need to be registered to access the Quartz patch)</em>. Once you have downloaded the patch, put it in the following folder:</p>
<p><strong> /Users/[you]/Library/Graphics/Quartz Composer Patches/ </strong></p>
<p>If the folder doesn&#8217;t already exist, CREATE IT!.</p>
<p><a href="http://www.codingcolor.com/wp-content/uploads/2011/05/Serail_iO.jpg"><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Serail_iO.jpg" alt="" title="Serail_iO" width="575" height="310" class="aligncenter size-full wp-image-3786" /></a></p>
<p>That pretty much covers the software needs for the Quartz Composer end of the equation. Now, lets focus on setting up your Arduino. Grab the Arduino, jumper wire and potentiometer. Connect a wire from one of the outer pins of the potentiometer to the ground pin on the Arduino. Connect another wire to the other outer pin of the potentiometer to the 5 volts pin on the Arduino . Lastly, connect a wire from the middle pin of the potentiometer to the analog input pin 0 on the Arduino.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/AnalogReadSerial_BB.png" alt="" title="AnalogReadSerial_BB" width="321" height="372" class="aligncenter size-full wp-image-3834" /></p>
<p>Connect your Arduino board via USB to your computer and open up the Arduino IDE.<br />
Go to Tools->Serial Port and choose the entry that reads /dev/tty.usbserial-XXXXXXXX. Take note of the Serial port location, we will need to add it as a variable to the Serial IO patch in the Quartz Composer composition.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-2.png" alt="" title="Picture 2" width="500" height="614" class="aligncenter size-full wp-image-3842" /></p>
<p>Next Go to Tools->Board and select your board.</p>
<p>You can either copy, type or download the source for the following Arduino sketch.</p>
<p><code class="codecolorer c mac-classic"><span class="c"><span style="color: #808080; font-style: italic;">/*<br />
This example shows the output of an analogRead() of a Potentiometer.<br />
By M.Gonzalez<br />
www.codingcolor.com<br />
The example code is in the public domain<br />
*/</span><br />
<span style="color: #993333;">int</span> potentiometerPin <span style="color: #339933;">=</span> A0<span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// select the input pin for the potentiometer</span><br />
<span style="color: #993333;">int</span> potentiometerValue <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">// variable to store the value coming from the potentiometer</span><br />
<br />
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; pinMode<span style="color: #009900;">&#40;</span>potentiometerPin<span style="color: #339933;">,</span> INPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// read the value from the potentiometer:</span><br />
&nbsp; potentiometerValue <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>potentiometerPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
&nbsp; <span style="color: #666666; font-style: italic;">// send the value to Quartz Composer with line break</span><br />
&nbsp; Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span> potentiometerValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></span></code></p>
<p>The sketch is relatively simple. All it&#8217;s doing is reading the input from the pot and printing the data. Upload the Sketch to your Arduino and open your Serial Monitor <em>(click on the button directly to the right of the &#8220;Upload&#8221; button)</em>. You should see a steady stream of numbers ranging from 0-1023, correlating to the position of the pot. As you turn your potentiometer, these numbers will respond almost instantly.  If all went well, you can close the Arduino Ide and open up Quartz Composer.</p>
<p>The first thing you will do is create a Blank Composition.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-17.png" alt="" title="QC_blank composition" width="625" height="561" class="aligncenter size-full wp-image-3853" /></p>
<p>Next, select the Patch Creator button, which will spawn the Patch Creator utility window. The window enables you to browse the available Quartz Composer patches and clips. When you select a patch name, you can read its description and pertinent information about the patch .</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/patch_library.jpg" alt="" title="patch_library" width="282" height="343" class="aligncenter size-full wp-image-3856" /></p>
<p>In the search bar enter the text &#8220;clear&#8221;. The results should display the Clear patch. The Clear patch paints the entire rendering destination (Viewer Window) with a constant color and clears the depth buffer. Either double click on the patch or drag it to the composition editor window. If the Viewer Window is open, you will notice that it&#8217;s now rendering a black screen. To change the color, you select the Clear patch in the Editor window and click on the Patch Parameters button on the toolbar at the top of the editor window.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-21.png" alt="" title="Patch Parameters" width="623" height="555" class="aligncenter size-full wp-image-3859" /></p>
<p>The patch parameters pane will be shown to the right of the workspace. The pane provides convenient access for editing input parameters. You will notice that the Clear Color input is set to black, this is where you would change the color if need be.</p>
<p>Next navigate back to the Patch Creator utility window and search for &#8220;Serial input&#8221;. If you followed the Quartz Composer set up, you will have successfully found the Serial input by Kineme. Double click on the Serial Input patch or drag it to the composition editor window. With the Kineme Serial Input patch selected in the editor window, select the Patch Inspector button on the toolbar to spawn the Patch Inspector utility window. Remember when I told you to take note of the Serial port location of your Arduino, well this is the time when you need it. Enter the location of your USB port, enter the Baud rate (by default 9600) and enter &#8216;\n&#8217; into the Break String input field.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-3.png" alt="" title="Picture 3" width="293" height="445" class="aligncenter size-full wp-image-3864" /></p>
<p>This Serial patch is all you need to receive data from your Arduino. Whatever the Arduino is printing out, will be available to the Quartz application. It is up to you to handle the data and transform it into a visual representation. </p>
<p>Navigate back to the Patch Creator utility window and run a search for &#8220;Image With String&#8221;. Double click on the patch or drag it to the composition editor window. Now here&#8217;s your first connection. Select the <strong>Data</strong> output on the Kineme Serial Input patch and connect it to the <strong>String</strong> input of the Image With String patch.</p>
<p><a href="http://www.codingcolor.com/wp-content/uploads/2011/05/1st_connection.jpg"><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/1st_connection.jpg" alt="" title="1st_connection" width="600" height="439" class="aligncenter size-full wp-image-3872" /></a></p>
<p>Navigate back to the Patch Creator utility window and run a search for “Billboard”. Double click on the patch or drag it to the composition editor window. Connect the <strong>Image</strong> output of the Image With String patch to the <strong>Image</strong> input on the Billboard patch. </p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/05/Picture-19.png" alt="" title="Final composition" width="697" height="518" class="aligncenter size-full wp-image-3886" /></p>
<p>There you have it, you should now be viewing the value of the Arduino pot in the Viewer Window. Turn the pot and the numbers will update in the viewer. This posting introduces you to the possibilities of interaction you can have between Quartz and the Arduino. If you are wondering if you can use Quartz to send data to Arduino, well the answer is yes, but I&#8217;ll save that for another post. For now get familiar with Quartz it&#8217;s a powerful application, take this example and plug it into a Particle system or make a blur filter. Swap out the pot for a Photocell, get creative!<br />
Enjoy!</p>
<a class="downloadlink" href="http://www.codingcolor.com/downloads/Potentiometer_example.zip" title="Version1.0 downloaded 9 times" >Quartz & Arduino (9)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/microcontrollers/quartz-composer-and-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The &#8216;Kinect&#8217; factor</title>
		<link>http://www.codingcolor.com/interactive-art/the-kinect-factor/</link>
		<comments>http://www.codingcolor.com/interactive-art/the-kinect-factor/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 04:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Interactive Art]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=3666</guid>
		<description><![CDATA[*UPDATE Awesomeness revealed: True API Support. The Microsoft Kinect Controller seems to be the HOT hackable item in the interactive art world. Just like the Wii Remote, the Kinect has been hacked by interactive artists to control robots, scan environments, create sound instruments and much,much more. The Kinect is a robust sensor which features an [...]]]></description>
			<content:encoded><![CDATA[<p>*UPDATE<br />
Awesomeness revealed:<br />
<a href="http://kinecthacks.net/microsoft-showcases-kinect-sdk-for-windows-7-releasing-this-spring/" target="blank">True API Support</a>.</p>
<p>The <a href="http://www.xbox.com/en-US/kinect" target="blank"><u>Microsoft Kinect Controller</u></a> seems to be the HOT hackable item in the interactive art world. Just like the <a href="http://en.wikipedia.org/wiki/Wii_Remote" target="blank"><u>Wii Remote</u></a>, the Kinect has been hacked by interactive artists to control robots, scan environments, create sound instruments and much,much more. The Kinect is a robust sensor which features an &#8220;RGB camera, depth sensor and multi-array microphone running proprietary software&#8221;, which provide full-body 3D motion capture, facial recognition and voice recognition capabilities. The Kinect Hacker community and the Open Sourcing of device drivers have enabled the Kinect controller to be used directly from connected PC’s operating on Windows 7. I&#8217;ve been following the development of interactive installations and experimentation&#8217;s utilizing the Kinect sensor. I felt it was time to list a few of my favorites. Being an AS3 engineer, it&#8217;s only natural I start off with some of the cool AS3 examples.</p>
<p>My favorite to date is the Touchless Kinect AS3 application, which is developed  with the <a href="http://www.as3kinect.org/api-documentation/openkinect-as3-api/" target="blank"><u>OpenKinect</u></a> AS3 API.<br />
<p><a href="http://www.codingcolor.com/interactive-art/the-kinect-factor/"><em>Click here to view the embedded video.</em></a></p></p>
<p><a href="http://silviopaganini.posterous.com/" target="blank"><u>Silvio Paganini</u></a> has also been quite busy, experimenting using AS3 <a href="http://bubblebird.at/tuioflash/tuio-as3-library" target="blank"><u>TUIO</u></a> and the <a href="http://gkaindl.com/software/udp-flashlc-bridge" target="blank"><u>UDP-Flash Bridge</u></a>.</p>
<p><a href="http://www.codingcolor.com/interactive-art/the-kinect-factor/"><em>Click here to view the embedded video.</em></a></p>
<p>If you are Windows person, you can now control apps on Windows 7.<br />
<p><a href="http://www.codingcolor.com/interactive-art/the-kinect-factor/"><em>Click here to view the embedded video.</em></a></p></p>
<p>The <a href="http://www.quadratura.info"><u>Quadratura</u></a> collective exhibited &#8220;Shadows of Light&#8221; a Kinect based art piece  at the Ambika Gallery in London.<br />
<p><a href="http://www.codingcolor.com/interactive-art/the-kinect-factor/"><em>Click here to view the embedded video.</em></a></p></p>
<p>Cyber Sex anyone? This maybe a bit weird but yes, people are taking it to the next level.<br />
<p><a href="http://www.codingcolor.com/interactive-art/the-kinect-factor/"><em>Click here to view the embedded video.</em></a></p></p>
<p>You can find more information regarding open source Kinect at <a href="http://openkinect.org/wiki/Main_Page" target="blank"><u>OpenKinect.org</u></a> and if you want to stay up on hacked Kinect news, visit <a href="http://kinecthacks.net/" target="blank"><u>Kinect Hacks</u></a>.</p>
<p>Now it&#8217;s only time till someone replicates the <a href="http://www.youtube.com/watch?v=NwVBzx0LMNQ" target="blank"><u>Minority Report</u></a>-like interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/interactive-art/the-kinect-factor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Embed My Font Utility</title>
		<link>http://www.codingcolor.com/as3/as3-embed-my-font-utility/</link>
		<comments>http://www.codingcolor.com/as3/as3-embed-my-font-utility/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 20:09:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Font]]></category>
		<category><![CDATA[TextField]]></category>
		<category><![CDATA[TextFormat]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=1367</guid>
		<description><![CDATA[Here&#8217;s a quick ActionScript font utility, that some of you flash devs may find useful. It uses the most popular way of embedding a font, by referencing a font symbol in the library. If you are not familiar with the process, the following are quick directions on how to create a font in the library. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick ActionScript font utility, that some of you flash devs may find useful. It uses the most popular way of embedding a font, by referencing a font symbol in the library. If you are not familiar with the process, the following are quick directions on how to create a font in the library.</p>
<p>(1) Open up your Library.<br />
(2) Select the upper-right corner of the Library panel pop up menu.<br />
(3) Select New Font.<br />
(4) Enter a name for the font in the Name field.<br />
(5) Select a font from the Font menu.<br />
(6) Select your desired font style (Regular, Italic, Bold, or Bold Italic) from the Style drop-down menu.</p>
<p><strong>*Note:</strong> The Size setting applies only when you use the Bitmap Text option. You&#8217;ll usually set the size of the text in a TextFormat object.</p>
<p>(8) Click the Advanced button<br />
(9) Click Export for ActionScript and enter a class name. </p>
<p><strong>*Note:</strong> I usually place my library items in a lib namespace, you don&#8217;t have to do that.</p>
<p>(10) Click OK.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2011/02/Picture-1.png" alt="" title="Picture 1" width="578" height="502" class="aligncenter size-full wp-image-3579" /></p>
<p>The font utility simply creates a TextFormat object and sets its fontFamily property to the name of the embedded font, and applies the TextFormat object to a given TextField. </p>
<p>The following is the example swf:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_FontUtil_2112067922"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="http://www.codingcolor.com/wp-content/uploads/2011/02/FontUtil.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.codingcolor.com/wp-content/uploads/2011/02/FontUtil.swf"
			name="fm_FontUtil_2112067922"
			width="550"
			height="400">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here&#8217;s the document class which displays examples on how to use the font utility.</p>
<p><code class="codecolorer actionscript3 mac-classic"><span class="actionscript3"><span style="color: #3f5fbf;">/*******************************<br />
* Author: Manuel Gonzalez &nbsp; &nbsp; &nbsp;*<br />
* www &nbsp; : www.codingcolor.com &nbsp;*<br />
* email : design@stheory.com &nbsp; *<br />
********************************/</span><br />
<span style="color: #9900cc; font-weight: bold;">package</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>TextFields<span style="color: #000066; font-weight: bold;">.</span>EmbedFontUtil<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>lib<span style="color: #000066; font-weight: bold;">.</span>Jazz<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>lib<span style="color: #000066; font-weight: bold;">.</span>Juice<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>lib<span style="color: #000066; font-weight: bold;">.</span>Banco<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>lib<span style="color: #000066; font-weight: bold;">.</span>HelveticaBlack<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextField</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> fl<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Button<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> DocApp <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> embedUtil &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">:</span>EmbedFontUtil<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> exampleString_1 <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'A dynamic TextField displaying the Jazz Font'</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> exampleString_2 <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'A dynamic TextField with a TextFormat displaying the Juice Font.'</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> exampleString_3 <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'The Banco Font, TextFormat and other crap!'</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> exampleString_4 <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'Displaying Helvetica Bold in a text field on stage.'</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> exampleString_5 <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'Press the button to change my font'</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">//</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> changeFontButton<span style="color: #000066; font-weight: bold;">:</span>Button<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> DocApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp;embedUtil = EmbedFontUtil<span style="color: #000066; font-weight: bold;">.</span>getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009966; font-style: italic;">/******** simple example with a dynamic text field *************/</span> <br />
<span style="color: #6699cc; font-weight: bold;">var</span> testField_1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span>LEFTtestField_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> JazzFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Jazz<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//make sure to import your font</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedFont<span style="color: #000000;">&#40;</span>testField_1<span style="color: #000066; font-weight: bold;">,</span>JazzFont<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = exampleString_1<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>testField_1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009966; font-style: italic;">/******** simple example with a text field placed manually on stage *********/</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> helveticaBlackFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> HelveticaBlack<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//make sure to import your font</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedFont<span style="color: #000000;">&#40;</span>textFieldOnStage<span style="color: #000066; font-weight: bold;">,</span>helveticaBlackFont<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
textFieldOnStage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = exampleString_4<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009966; font-style: italic;">/****************************************************************************/</span><br />
<br />
<span style="color: #009966; font-style: italic;">/******** example with a dynamic text field &amp; TextFormat object ************/</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> testField_2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> format_1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">color</span> = 0xff00ff<span style="color: #000066; font-weight: bold;">;</span><br />
format_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> juiceFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Juice<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//make sure to import your font</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedFont<span style="color: #000000;">&#40;</span>testField_2<span style="color: #000066; font-weight: bold;">,</span>juiceFont<span style="color: #000066; font-weight: bold;">,</span>format_1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = &nbsp;exampleString_2<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>testField_2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009966; font-style: italic;">/************************************************************************/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009966; font-style: italic;">/******** example with a dynamic textfield &amp; properties including TextFormat**********/</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> testField_3<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">22</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">background</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">backgroundColor</span> = 0x000000<span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xffffff<span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">85</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #6699cc; font-weight: bold;">var</span> format_3<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CENTER</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span> = <span style="color: #990000;">&quot;http://codingcolor.com&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
format_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">underline</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #6699cc; font-weight: bold;">var</span> bancoFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Banco<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//make sure to import your font</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedFont<span style="color: #000000;">&#40;</span>testField_3<span style="color: #000066; font-weight: bold;">,</span>bancoFont<span style="color: #000066; font-weight: bold;">,</span>format_3<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
testField_3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = &nbsp;exampleString_3<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>testField_3<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009966; font-style: italic;">/*************** example with a textfield on stage preserve format and string change font ****/</span><br />
createButtonUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = exampleString_5<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #3f5fbf;">/*<br />
Method: createButtonUI<br />
Parameters:<br />
Returns:<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createButtonUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
changeFontButton = <span style="color: #0033ff; font-weight: bold;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontButton<span style="color: #000066; font-weight: bold;">.</span>move<span style="color: #000000;">&#40;</span>changeFontField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>changeFontField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> changeFontField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;Change Font&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;textFormat&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Helvetica Black&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
changeFontButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> changeTheFont<span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>changeFontButton<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/*<br />
Method: changeTheFont<br />
Parameters:<br />
evt:MouseEvent<br />
Returns:<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> changeTheFont<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> JazzFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Jazz<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedNewFontPreserveString<span style="color: #000000;">&#40;</span>changeFontField<span style="color: #000066; font-weight: bold;">,</span>JazzFont<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color: #000000;">&#125;</span></span></code></p>
<p>As you can see it&#8217;s pretty simple to use:<br />
<code class="codecolorer actionscript3 mac-classic"><span class="actionscript3"><span style="color: #6699cc; font-weight: bold;">var</span> helveticaBlackFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> HelveticaBlack<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
embedUtil<span style="color: #000066; font-weight: bold;">.</span>embedFont<span style="color: #000000;">&#40;</span>textFieldOnStage<span style="color: #000066; font-weight: bold;">,</span>helveticaBlackFont<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
textFieldOnStage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = exampleString_4<span style="color: #000066; font-weight: bold;">;</span></span></code></p>
<p>Download the class and files below.<br />
Enjoy!<br />
<a class="downloadlink" href="http://www.codingcolor.com/downloads/Embed_Font.zip" title="Version1.0 downloaded 41 times" >Font Embed Util (41)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/as3/as3-embed-my-font-utility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s my text string width?</title>
		<link>http://www.codingcolor.com/as3/whats-my-text-string-width-or-height/</link>
		<comments>http://www.codingcolor.com/as3/whats-my-text-string-width-or-height/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 06:44:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[combo box component]]></category>
		<category><![CDATA[TextField]]></category>
		<category><![CDATA[TextField.height]]></category>
		<category><![CDATA[TextField.width]]></category>
		<category><![CDATA[textHeight]]></category>
		<category><![CDATA[textWidth]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=3518</guid>
		<description><![CDATA[Here we go again, another snippet into a flash devs mind. Have you&#8217;ve ever been tasked with localizing a flash application? Have you ever had the need to determine the width of a string prior to displaying it in a text field? Just recently I had to localize an application in 4 languages, which meant [...]]]></description>
			<content:encoded><![CDATA[<p>Here we go again, another snippet into a flash devs mind.  Have you&#8217;ve ever been tasked with localizing a flash application? Have you ever had the need to determine the width of a string prior to displaying it in a text field? Just recently I had to localize an application in 4 languages, which meant my user interface/design would have to adjust depending on the language or translated string being displayed. I had an issue where I had a combo box on stage which needed to re-size based on the width of the longest string in its DataProvider. The issue spawned a quick and dirty solution which will be helpful to some.<br />
The idea is to take a string, create a text field, provide the text field with the string and determine the text fields width. In a nut shell that&#8217;s what the class does. It also has a method that will determine the widest string out of an array of strings.</p>
<p>To state the obvious, flash readily allows a few ways to read the width and height of a <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.htmt" target="blank">TextField</a> display object.<br />
You can use the following properties of the TextField class:</p>
<p>textWidth: The width of the text in pixels.<br />
textHeight: The height of the text in pixels</p>
<p>Or get the width and height using the TextField width and height properties, which will include the invisible frame which surrounds the text field.</p>
<p>TextField.width:  The width of the TextField in pixels.<br />
TextField.height:  The width of the TextField in pixels.</p>
<p>And last but not least you can use the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextLineMetrics.html?filter_flex=4.1&#038;filter_flashplayer=10.1&#038;filter_air=2" target="blank">TextLineMetrics</a> class which will contain information about the text position and pixel measurements of a line of text within a text field.</p>
<p>Anyhow the following example below displays two examples of the the StringUtils.as class in action. The first example takes a string and returns its width and height value which in turn uses the dimensions to display a blue rectangle. The Second examples takes in an array of strings and returns a number which represents the widest string in the array, which in turn uses the width dimension to display a red rectangle.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_StringHelper_581767168"
			class="flashmovie"
			width="250"
			height="200">
	<param name="movie" value="http://www.codingcolor.com/wp-content/uploads/2011/01/StringHelper.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.codingcolor.com/wp-content/uploads/2011/01/StringHelper.swf"
			name="fm_StringHelper_581767168"
			width="250"
			height="200">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here&#8217;s the StringUtils.as class in its entirety. </p>
<p><code class="codecolorer actionscript3 mac-classic"><span class="actionscript3"><span style="color: #3f5fbf;">/************************************<br />
* @author : Manuel Gonzalez &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* @blog &nbsp; : www.codingcolor.com &nbsp; &nbsp; *<br />
* @email &nbsp;: design@stheory.com &nbsp; &nbsp; &nbsp;*<br />
* @www&nbsp; &nbsp; : www.stheory.com &nbsp; &nbsp; &nbsp; &nbsp; *<br />
************************************/</span><br />
<span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>utils<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextField</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextLineMetrics</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> StringUtils<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> StringUtils<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: getTextLineWidth<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; inStr:String<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFont:Font<br />
&nbsp; &nbsp; &nbsp; &nbsp; inTextFormat:TextFormat=null<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getTextLineWidth<span style="color: #000000;">&#40;</span>inStr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> inFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">,</span>inTextFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>inTextFormat == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = inFont<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rightMargin</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = inTextFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> testField<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">wordWrap</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">defaultTextFormat</span> = tFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = inStr<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: getTextLineHeight<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; inStr:String<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFont:Font<br />
&nbsp; &nbsp; &nbsp; &nbsp; inTextFormat:TextFormat=null<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getTextLineHeight<span style="color: #000000;">&#40;</span>inStr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> inFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">,</span>inTextFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>inTextFormat == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = inFont<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rightMargin</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = inTextFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> testField<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">wordWrap</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">defaultTextFormat</span> = tFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = inStr<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: getTextWidthAndHeight<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; inStr:String<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFont:Font<br />
&nbsp; &nbsp; &nbsp; &nbsp; inTextFormat:TextFormat=null<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Object {width:,height:}<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getTextWidthAndHeight<span style="color: #000000;">&#40;</span>inStr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> inFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">,</span>inTextFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> textObj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>inTextFormat == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = inFont<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rightMargin</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = inTextFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> testField<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">wordWrap</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">defaultTextFormat</span> = tFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = inStr<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> textObj<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: getWidthOfLongestStringInArray<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; inArray:Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFont<br />
&nbsp; &nbsp; &nbsp; &nbsp; inTextFormat=null<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getWidthOfLongestStringInArray<span style="color: #000000;">&#40;</span>inArray<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">,</span>inFont<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">,</span>inTextFormat=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> wResult<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tFormat<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>inTextFormat == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">size</span> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">TextFormatAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = inFont<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rightMargin</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tFormat = inTextFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = inArray<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> =<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> len<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> testField<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">wordWrap</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">defaultTextFormat</span> = tFormat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = inArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> stringWidth<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>testField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>stringWidth <span style="color: #000066; font-weight: bold;">&gt;</span> wResult<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wResult = stringWidth<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> wResult<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></span></code></p>
<p>The download provides the above example including the StringUtils.as class.<br />
Enjoy!</p>
<a class="downloadlink" href="http://www.codingcolor.com/downloads/StringHelper.zip" title="Version1.0 downloaded 27 times" >StringHelper (27)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/as3/whats-my-text-string-width-or-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook country list</title>
		<link>http://www.codingcolor.com/as3/facebook-country-list/</link>
		<comments>http://www.codingcolor.com/as3/facebook-country-list/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 21:09:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[countries]]></category>
		<category><![CDATA[country list]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ISO]]></category>
		<category><![CDATA[support]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=3431</guid>
		<description><![CDATA[Facebook, Facebook, Facebook, how I despise thee. I&#8217;m in the middle of developing a Flash based Facebook application, which requires the ability for a user to view particular images in Facebook supported countries. I assumed Facebook had some sort of API which would return the countries they support. But as it turns out, they dont. [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook, Facebook, Facebook, how I despise thee. I&#8217;m in the middle of developing a Flash based Facebook application, which requires the ability for a user to view particular images in Facebook supported countries. I assumed Facebook had some sort of API which would return the countries they support. But as it turns out, they dont. Facebook groups countries by locale and language as demonstrated by Facebook&#8217;s locale xml :  <a href="http://www.facebook.com/translations/FacebookLocales.xml" target="blank"><u> http://www.facebook.com/translations/FacebookLocales.xml</u></a> .<br />
Not really usable in regards to what I need, but I can work with it. The widget below is a tool I created which takes the FacebookLocales.xml and the <a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm" target="blank"><u>ISO 3166 code lists</u></a> and spits out the countries that Facebook supports, in either xml format or an array of objects. I thought this would be useful for you other flash devs out there.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_fb_1317092026"
			class="flashmovie"
			width="500"
			height="600">
	<param name="movie" value="http://www.stheory.com/codingColor/facebook/fb.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.stheory.com/codingColor/facebook/fb.swf"
			name="fm_fb_1317092026"
			width="500"
			height="600">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The code is quite simple :</p>
<p><code class="codecolorer actionscript3 mac-classic"><span class="actionscript3"><span style="color: #3f5fbf;">/****************************<br />
* Manuel Gonzalez &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* design@stheory.com &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* www.stheory.com &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* www.codingcolor.com &nbsp; &nbsp; &nbsp; *<br />
*****************************/</span><br />
<span style="color: #9900cc; font-weight: bold;">package</span> <br />
<span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Security</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">System</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> fl<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Button<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> fl<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>TextArea<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> fl<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>RadioButton<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> fl<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>RadioButtonGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLLoader</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Loader</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextField</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFieldAutoSize</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Dictionary</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> DocApp <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> facebookXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;FacebookLocales.xml&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> isoXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;iso_3166-1_list_en.xml&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> facebookCountryCodes<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> isoDataArray<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> finalCountriesData<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> outputField<span style="color: #000066; font-weight: bold;">:</span>TextArea<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> printOutputButton<span style="color: #000066; font-weight: bold;">:</span>Button<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> clipBoardButton<span style="color: #000066; font-weight: bold;">:</span>Button<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> rbg<span style="color: #000066; font-weight: bold;">:</span>RadioButtonGroup<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> DocApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Security</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">loadPolicyFile</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;your_path_to_cross_domain.xml&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;loading data&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadXML<span style="color: #000000;">&#40;</span>facebookXml<span style="color: #000066; font-weight: bold;">,</span> fbXMLLoaded<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: loadXML<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: <br />
&nbsp; &nbsp; &nbsp; &nbsp; inPath:String<br />
&nbsp; &nbsp; &nbsp; &nbsp; inCallback:Function<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loadXML<span style="color: #000000;">&#40;</span>inPath<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> inCallback<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> req<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span>inPath<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> inCallback<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>req<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: fbXMLLoaded<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: evt:Event<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fbXMLLoaded<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> theXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parseFbXml<span style="color: #000000;">&#40;</span>theXml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arrayRemoveDup<span style="color: #000000;">&#40;</span>facebookCountryCodes<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadXML<span style="color: #000000;">&#40;</span>isoXml<span style="color: #000066; font-weight: bold;">,</span> isoXMLLoaded<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: isoXMLLoaded<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: evt:Event<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> isoXMLLoaded<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> theXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parseIsoXml<span style="color: #000000;">&#40;</span>theXml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildCountryData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Data Ready&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: parseIsoXml<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: inXml:XML<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> parseIsoXml<span style="color: #000000;">&#40;</span>inXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = inXml <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isoDataArray = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> numCountries<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>ISO_3166_1_Entry<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> numCountries<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> current<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>ISO_3166_1_Entry<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> cObj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span> = current<span style="color: #000066; font-weight: bold;">.</span>ISO_3166_1_Alpha_2_Code_element<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cObj<span style="color: #000066; font-weight: bold;">.</span>label = current<span style="color: #000066; font-weight: bold;">.</span>ISO_3166_1_Country_name<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isoDataArray<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>cObj<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: parseFbXml<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: inXml:XML<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> parseFbXml<span style="color: #000000;">&#40;</span>inXml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = inXml <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; facebookCountryCodes = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> numLocales<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>locale<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> =<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span> numLocales<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> current<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>locale<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> rep<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = current<span style="color: #000066; font-weight: bold;">.</span>codes<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">code</span><span style="color: #000066; font-weight: bold;">.*.</span>representation<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> pos<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = rep<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;_&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> countryCode<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = rep<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">substr</span><span style="color: #000000;">&#40;</span>pos <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; facebookCountryCodes<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>countryCode<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: buildCountryData<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> buildCountryData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = facebookCountryCodes<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finalCountriesData = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> len<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> codeStr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = facebookCountryCodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> isolen<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = isoDataArray<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&lt;</span> isolen<span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>codeStr<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toLowerCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == isoDataArray<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toLowerCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finalCountriesData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>isoDataArray<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: createUI<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns: &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField = <span style="color: #0033ff; font-weight: bold;">new</span> TextArea<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span>setSize<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">500</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span>move<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>outputField<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton = <span style="color: #0033ff; font-weight: bold;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">75</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span>move<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">450</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;Print&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;textFormat&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Arial&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span>toggle = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printOutputButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> printToOutputField<span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>printOutputButton<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton = <span style="color: #0033ff; font-weight: bold;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">125</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span>move<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">225</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">550</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;Copy To Clipboard&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;textFormat&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Arial&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span>toggle = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clipBoardButton<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> copyData<span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>clipBoardButton<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rbg = <span style="color: #0033ff; font-weight: bold;">new</span> RadioButtonGroup<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;options&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createRadioButton<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Xml&quot;</span><span style="color: #000066; font-weight: bold;">,</span> rbg<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">225</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createRadioButton<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Array of Obj&quot;</span><span style="color: #000066; font-weight: bold;">,</span> rbg<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">325</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: copyData<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: evt:MouseEvent<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> copyData<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; copyToClipboard<span style="color: #000000;">&#40;</span>outputField<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: printToOutputField<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: evt:MouseEvent<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> printToOutputField<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rbg<span style="color: #000066; font-weight: bold;">.</span>selection == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rbg<span style="color: #000066; font-weight: bold;">.</span>selection<span style="color: #000066; font-weight: bold;">.</span>label == <span style="color: #990000;">&quot;Xml&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printXMLToOutput<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printObjArrayToOutput<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: createRadioButton<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; rbLabel:String<br />
&nbsp; &nbsp; &nbsp; &nbsp; rbg:RadioButtonGroup<br />
&nbsp; &nbsp; &nbsp; &nbsp; xpos:Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; ypos:Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createRadioButton<span style="color: #000000;">&#40;</span>rbLabel<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> rbg<span style="color: #000066; font-weight: bold;">:</span>RadioButtonGroup<span style="color: #000066; font-weight: bold;">,</span>xpos<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span>ypos<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> rb<span style="color: #000066; font-weight: bold;">:</span>RadioButton = <span style="color: #0033ff; font-weight: bold;">new</span> RadioButton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rb<span style="color: #000066; font-weight: bold;">.</span>group = rbg<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rb<span style="color: #000066; font-weight: bold;">.</span>label = rbLabel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rb<span style="color: #000066; font-weight: bold;">.</span>move<span style="color: #000000;">&#40;</span>xpos<span style="color: #000066; font-weight: bold;">,</span> ypos<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>rb<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: copyToClipboard<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: inTf:*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> copyToClipboard<span style="color: #000000;">&#40;</span>inTf<span style="color: #000066; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">System</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setClipboard</span><span style="color: #000000;">&#40;</span>inTf<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: printObjArrayToOutput<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> printObjArrayToOutput<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finalCountriesData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sortOn</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;label&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = finalCountriesData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">'var facebookCountries:Array = ['</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> len<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>i == len <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'{value:'</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&quot;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&quot;'</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">',label:&quot;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&quot;}];'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'{value:&quot;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&quot;,label:&quot;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&quot;},<span style="">\n</span>'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: printXMLToOutput<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> printXMLToOutput<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">'&lt;facebook_countries_en xml:lang=&quot;en&quot;&gt; <span style="">\n</span>'</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finalCountriesData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sortOn</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;label&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = finalCountriesData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> len<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'&lt;country_entry&gt; <span style="">\n</span>'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">' &lt;country_code&gt;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&lt;/country_code&gt; <span style="">\n</span>'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">' &lt;country_name&gt;'</span><span style="color: #000066; font-weight: bold;">+</span>finalCountriesData<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">'&lt;/country_code&gt; <span style="">\n</span>'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'&lt;/country_entry&gt; <span style="">\n</span>'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'&lt;facebook_countries_en&gt;'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009966; font-style: italic;">/***************** HELPER METHODS *********************************/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Method: arrayRemoveDup<br />
&nbsp; &nbsp; &nbsp; &nbsp; Parameters: inArry:Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> arrayRemoveDup<span style="color: #000000;">&#40;</span>inArry<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">,</span>j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> inArry<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>j = i <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&lt;</span> inArry<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>inArry<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> === inArry<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inArry<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">splice</span><span style="color: #000000;">&#40;</span>j<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></span></code></p>
<p>The code loads up FacebookLocale.xml, parses it and creates a facebook country code array. I proceed by removing duplicates in the array. Next, I load up the countries ISO xml , parse it and create a countries ISO data array with objects that contain the country name and country code. Lastly, I build my final country array by taking the Facebook country codes and searching for them in the countries ISO data array. If a country is found the ISO data Object is pushed to the final array. The rest of the code supports the UI.  I&#8217;ve included everything you need in the download below. To keep the country list up to date you should always download the necessary xml files:<br />
<a href="http://www.facebook.com/translations/FacebookLocales.xml" target="blank"><br />
<u>FacebookLocale.xml</u></a><br />
<a href="http://www.iso.org/iso/iso_3166-1_list_en.zip" target="blank"><u>iso_3166-1_list_en.zip</u></a></p>
<p>Also, Flash does not like the dash&#8217;s in the iso_3166-1_list_en.xml. If you download the zip from ISO and compare it with the xml I provided for you in the download, you will notice I replaced the dash with an underscore.<br />
**** NOTE the duplicate function is not efficient, look over your output for doubles. I&#8217;ll release the fix when I get around to it. If you solved it, please post it &#8230;keep ActionScript open source.<br />
Anyhow, enjoy!</p>
<a class="downloadlink" href="http://www.codingcolor.com/downloads/facebook_countries.zip" title="Version0.01 downloaded 36 times" >Facebook country list (36)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/as3/facebook-country-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I ♥ the Arduino Pro Mini</title>
		<link>http://www.codingcolor.com/microcontrollers/i-the-arduino-pro-mini/</link>
		<comments>http://www.codingcolor.com/microcontrollers/i-the-arduino-pro-mini/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 07:05:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Micro Controllers]]></category>
		<category><![CDATA[Arduino Pro Mini]]></category>
		<category><![CDATA[Arduino Pro Mini 328 - 5V]]></category>
		<category><![CDATA[BreadBoard]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[RAW]]></category>
		<category><![CDATA[RESET]]></category>
		<category><![CDATA[right angle headers]]></category>
		<category><![CDATA[straight headers]]></category>
		<category><![CDATA[VCC]]></category>

		<guid isPermaLink="false">http://www.codingcolor.com/?p=3251</guid>
		<description><![CDATA[I assume you have either made the leap from the Arduino Duemilanove to an Arduino Pro Mini or you are contemplating to do so. In a nutshell the Arduino Pro Mini is basically an Arduino Duemilanove ATMega328 without a USB port and FTDI chip. It&#8217;s a really small board, approximately 0.7&#8243; x 1.3&#8243;. You can [...]]]></description>
			<content:encoded><![CDATA[<p>I assume you have either made the leap from the <a href="http://www.sparkfun.com/products/666" target="blank"><u>Arduino Duemilanove</u></a> to an <a href="http://www.arduino.cc/en/Main/ArduinoBoardProMini" target="blank"><u>Arduino Pro Mini</u></a> or you are contemplating to do so. In a nutshell the Arduino Pro Mini is basically an Arduino Duemilanove ATMega328 without a USB port and FTDI chip. It&#8217;s a really small board, approximately 0.7&#8243; x 1.3&#8243;. You can find Arduino Pro Mini&#8217;s in semi-permanent installations, in objects or exhibitions, where the engineers had limited space or wanted to conceal the micro-controller.<br />
<img src="http://www.codingcolor.com/wp-content/uploads/2010/11/ArduinoProMini-300x168.jpg" alt="" title="ArduinoProMini" width="300" height="168" class="aligncenter size-medium wp-image-3310" /><br />
It&#8217;s pretty much my go to micro-controller when prototyping interactive applications. A side from being tiny, it&#8217;s the least expensive of the Arduino family, at $18 a piece. Since the Arduino Pro Mini does not have a USB port or FTDI chip, you will need a serial connection to program the board. I recommend the <a href="http://www.sparkfun.com/products/9716" target="blank"><u>SparkFuns FTDI Basic board</u></a>.<br />
<img src="http://www.codingcolor.com/wp-content/uploads/2010/11/Picture-2-300x215.png" alt="" title="new basic board" width="300" height="215" class="aligncenter size-medium wp-image-3329" /> You only have to buy one FTDI Basic board, to program as many Arduino Pro Mini(s) you can afford. </p>
<p>The Arduino Pro Mini comes in two flavors, 3.3 volt or 5 volt. I prefer the 5 volt option. I alter the voltage when need be, especially when working with sensors that operate at 3.3V . A few other things you will find a bit different migrating from the Duemilanove are the RAW, VCC and RESET pins.  The RAW pin enables you to supply the board with a raw unregulated voltage (5-12 volts, depending on the model). The VCC pins requires a regulated 3.3 or 5 volt supply (once again, depending on the model) to power the board. I usually power the board via the RAW pin and use the VCC pin to output a regulated 5v power source. The RESET pin is typically used to add a reset button to shields which block the one on the board. </p>
<p>You will notice that the board has analog pins 4(sda) and 5(scl) on the interior of the board. Pins 4 and 5 have a specialized functionality. The pins are used to support I2C (TWI) communications using the <a href="http://www.arduino.cc/en/Reference/Wire" target="blank"><u>Wire library</u></a>. That pretty much sums up the differences between the Duemilanove beginners board and the Arduino Pro Mini. I love the size of the Pro Mini. It compliments most of my prototyping applications and gives me the inputs and outputs I have grown to love from the  Duemilanove. </p>
<p>I recommend you take an Arduino Pro Mini and set it up to be Breadboard friendly. To do this you will need a medium size Breadboard, a set of <a href="http://www.sparkfun.com/products/116" target="blank">straight headers</a> and (optional) a set of <a href="http://www.sparkfun.com/products/553" target="blank">Right Angle</a> breakaway headers. The next steps provide you with info on how to set up your Arduino Pro Mini to be Breadboard friendly.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2010/11/setUpProMini.jpg" alt="" title="setUpProMini" width="500" height="400" class="aligncenter size-full wp-image-3340" /></p>
<p>Take the break away headers and cut them to fit the Arduino Pro Mini. You will need (2) 12 pin headers, (1) 6 pin header and (1) 2 pin header.</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2010/11/setUpProMini_breakaway.jpg" alt="" title="setUpProMini_breakaway" width="500" height="400" class="aligncenter size-full wp-image-3343" /></p>
<p>Now get your soldering iron out and lets solder the headers onto the board. The first thing I do is solder the 6 pin header to the top of the Arduino board. This is where the Arduino board will connect with the Basic FTDI board. I prefer to use Right Angle headers for the 6 pin. Place the 6 pin header on the Arduino board and flip the board over keeping the header pins in place and solder. Take a pair of wire snipers and snip the excess wire from the bottom of the board to allow the Arduino Mini to set flush up against a Breadboard. You should now have an Arduino board that looks like this (if you used the Right angle header):</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2010/11/proMiniTopHeader.jpg" alt="" title="proMiniTopHeader" width="174" height="295" class="aligncenter size-full wp-image-3347" /></p>
<p>Next, grab the medium size Breadboard and insert the 2 pin header into the Breadboard (shorter side of the pins up). Then flip the Arduino board over (backside up) and set the analog A4 and A5 holes of the Arduino onto the header pins. Align the Arduino board parallel to the Breadboard and solder. When you are done grab your snipers and cut the excess wire on the bottom of the Arduino board. You should now have 2 pins sticking out of the top of the Arduino board, enabling access to analog pins 4 and 5. </p>
<p>Placing the headers on a Breadboard prior to soldering helps, keep the Arduino Mini in place. In the next step we use this technique to add the 12 pin headers.</p>
<p>Simply place one of the 12 pin headers (short side of the pins up) onto the Breadboard. Place the Arduino Mini (top side up) onto the header. Take a mental note of the placement of the holes in relation to the Breadboard and place the other 12 pin header in its place. You should now have a stable Arduino Mini sitting on top of the 12 pin headers. All you have left to do is solder the headers in place. The end result should look like this:</p>
<p><img src="http://www.codingcolor.com/wp-content/uploads/2010/11/setUpProMini_final.jpg" alt="" title="setUpProMini_final" width="243" height="376" class="aligncenter size-full wp-image-3375" /></p>
<p>That concludes my instructional. </p>
<p>I have one more cool tip for you. Look into <a href="http://shop.moderndevice.com/products/wired-breadboard" target="blank"><u>Modern Devices wired Breadboard</u></a>. They make a foolproof beginners PCB board  that enables you to transfer your project directly from your solderless breadboard to the PCB, now that&#8217;s cool!  This is just the tip of the iceberg, I will release other topics primarily featuring the Arduino Pro Mini, so subscribe to my <a href="http://www.codingcolor.com/feed/" target="blank"><u>RSS</u></a> feed to get the latest and greatest on my Arduino adventures.<br />
Till next time, Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingcolor.com/microcontrollers/i-the-arduino-pro-mini/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

