<?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>Interactive IQ : The Hessler Design Blog</title>
	<atom:link href="http://www.hesslerdesign.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hesslerdesign.com/blog</link>
	<description>Smart Developers = Smart Websites</description>
	<lastBuildDate>Fri, 18 May 2012 17:08:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Have You Googled Yourself Lately?</title>
		<link>http://www.hesslerdesign.com/blog/blogging/have-you-googled-yourself-lately/</link>
		<comments>http://www.hesslerdesign.com/blog/blogging/have-you-googled-yourself-lately/#comments</comments>
		<pubDate>Fri, 18 May 2012 17:08:01 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[web presence]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=819</guid>
		<description><![CDATA[Well, have you? It&#8217;s a legit question. I think that at some point in time, almost everyone Googles their name to see what comes up. Probably the most common reason for doing this is to see where you site ranks, or if there are other people with the same name out there (in which case [...]]]></description>
			<content:encoded><![CDATA[<p>Well, have you? It&#8217;s a legit question. I think that at some point in time, almost everyone Googles their name to see what comes up. Probably the most common reason for doing this is to see where you site ranks, or if there are other people with the same name out there (in which case you may need to bump up your SEO to get ahead of them). Probably the next most common reason is to see all of the places you&#8217;re mentioned on the Web (or at least within the first few pages of results). It was for this reason that I Googled myself the other day.</p>
<p>When I Googled myself, I wasn&#8217;t so worried about the SEO aspect of my own sites, but wanted to see where I was being mentioned on the Web. Turns out, there aren&#8217;t a whole lot of places I&#8217;m mentioned, which is exactly what I expected. And while there are a few other people out there with my same name (even a Chicago-based metal band), I didn&#8217;t see too much out of the ordinary that I needed to worry about. </p>
<p>The main thing that I noticed was that there were a handful of websites that I had used once-upon-a-time for portfolio hosting and job searching that had some really old information about me, and equally as old work of mine displayed. Some of the sites I don&#8217;t even remember ever using, and was surprised that I showed up in their system. So I used my self-Googled time to scrub through the results, and visited (almost) all of the sites where I was mentioned. In most cases, I did something simple like update a profile picture or my bio. In other cases, I ended up deleting my accounts that had the old info and work samples. While I could&#8217;ve gone through the process of updating those sites, I found those particular ones to have never been too fruitful in any of my job searches. I mean really, in this day and age, as a Web developer, if I can&#8217;t make my own portfolio site and have to rely on another hosted site, then any job I may ever try to get is in fairly serious peril. </p>
<p>So, the moral of my story: Google yourself some time. You may find that it&#8217;s time for some much-needed spring cleaning to get your Web presence accurate and back in order.</p>
<p>Until next time, happy coding and Googling!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/blogging/have-you-googled-yourself-lately/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looping Through an Object in Flash ActionScript 3.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/looping-through-an-object-in-flash-actionscript-3-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/looping-through-an-object-in-flash-actionscript-3-0/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 23:00:41 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[object]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=810</guid>
		<description><![CDATA[Here&#8217;s an oldie but a goodie. You&#8217;re working in Flash, making calls to retrieve data from a server, and you get back an Object rather than XML. No problem! You can still loop through the Object just fine with a slight modification to your loop logic you&#8217;re used to using when parsing through XML. In [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an oldie but a goodie. You&#8217;re working in Flash, making calls to retrieve data from a server, and you get back an Object rather than XML. No problem! You can still loop through the Object just fine with a slight modification to your loop logic you&#8217;re used to using when parsing through XML. In the sample below, you can obviously assume that &#8220;myObject&#8221; is the Object you&#8217;re looping through. Also, the example code is just set to trace out the attribute name and value. Beyond that, you can do anything you want with the data. Here&#8217;s how your loop will look:<br />
<code><br />
<span style="color: #0000ff;">for</span> each (<span style="color: #0000ff;">var</span> attr:<span style="color: #0000ff;">*</span> <span style="color: #0000ff;">in</span> myObject.<span style="color: #0000ff;">elements</span>()) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0000ff;">trace</span>(<span style="color: #009900;">"Object Name: "</span> + attr.<span style="color: #0000ff;">name</span>());<br />
&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0000ff;">trace</span>(<span style="color: #009900;">"Object Value: "</span> + attr);<br />
}<br />
</code><br />
And that&#8217;s all there is to it. Simple and straightforward. But a good reference to have the next time you have to loop through and Object.</p>
<p>Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/looping-through-an-object-in-flash-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exercising Caution with Pathing and Class Naming in Flash</title>
		<link>http://www.hesslerdesign.com/blog/flash/exercising-caution-with-pathing-and-class-naming-in-flash/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/exercising-caution-with-pathing-and-class-naming-in-flash/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 23:00:19 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=800</guid>
		<description><![CDATA[Recently I was working on a project where I had a container SWF file, which loaded two different SWF files into it. Pretty straight forward stuff, and nothing I haven&#8217;t done before. However, my surprise came when I was adding a preloader movieclip in one of the loaded SWF files. Here&#8217;s what happened: In my [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a project where I had a container SWF file, which loaded two different SWF files into it. Pretty straight forward stuff, and nothing I haven&#8217;t done before. However, my surprise came when I was adding a preloader movieclip in one of the loaded SWF files. Here&#8217;s what happened:</p>
<p>In my container SWF, I had a library item set to export with class name &#8220;PreloaderMC&#8221;. As you might imagine, I created and added this preloader to the stage when my two SWF files were loading, then removed it from the display list once everything was loaded. I also had a library item exporting as &#8220;PreloaderMC&#8221; in one of my loaded SWF files. When testing and exporting the loaded SWF by itself, there was no issue. However, when I loaded that SWF into the container SWF, the preloader that was created and used in the loaded SWF was the one from the container SWF.</p>
<p>After asking a few colleagues and perusing some of the documentation, this wasn&#8217;t necessarily an unexpected find. It all has to do with application domain, which I won&#8217;t go into detail about here. In short though, if you use Loader.load() when loading another SWF file, and don&#8217;t specify LoaderContext (which, among other things, defines the ApplicationDomain for the loaded object), then the loaded SWF is considered a child domain of the container SWF, and thereby uses whatever class definitions are in the container that may have the same names.</p>
<p>So, lesson learned. Either be more explicit about specifying the application domain when loading external SWF files, or just use unique class names for item that are set to export to ActionScript.</p>
<div style="padding:16px 24px 16px 24px; background:#ededed; border:1px solid #dedede;">For more information about working with application domains, you can check out the <a href="http://help.adobe.com/en_US/as3/dev/WSd75bf4610ec9e22f43855da312214da1d8f-8000.html" title="Working with application domains" target="_blank">Adobe documentation on working with application domains</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/exercising-caution-with-pathing-and-class-naming-in-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dropping the Ball on Mobile Application Development</title>
		<link>http://www.hesslerdesign.com/blog/flash/dropping-the-ball-on-mobile-application-development/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/dropping-the-ball-on-mobile-application-development/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 18:30:23 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=786</guid>
		<description><![CDATA[OK. I need to get this off my chest. I&#8217;m not a fan of Adobe&#8217;s attempt to get into the mobile application game. There. I said it. That feels better. But why am I not a fan of what they&#8217;ve done? Quite frankly, in the process of trying to build a mobile application with Flash [...]]]></description>
			<content:encoded><![CDATA[<p>OK. I need to get this off my chest. I&#8217;m not a fan of Adobe&#8217;s attempt to get into the mobile application game.</p>
<p>There. I said it. That feels better.</p>
<p>But why am I not a fan of what they&#8217;ve done? Quite frankly, in the process of trying to build a mobile application with Flash Builder 4.5, I&#8217;m finding myself either engineering components from scratch, or reengineering the default &#8220;mobile-optimized&#8221; components to get them to do what I want/need. Plus, I&#8217;m finding that in an application of even a decent size (more than just a &#8220;hello world&#8221; app with a couple simple views like Adobe likes to show off to get Flash developers excited about mobile apps), the optimization and performance are still lacking.</p>
<p>Maybe I&#8217;m just being pessimistic. And maybe I&#8217;m not doing everything correctly to get things optimized for the mobile app. Honestly, I hope that I am missing something that I&#8217;ll catch soon and have a light bulb-over-the-head moment. But my experience thus far has taught me that Steve Jobs was right in bashing Adobe&#8217;s ability to create mobile-optimized content.</p>
<p>Here&#8217;s a snippet from a blog post from Steve Jobs, dated April 2010:</p>
<div style="padding: 16px 24px 16px 24px; background: #ededed; border: 1px solid #dedede;">
<p><em>“We know from painful experience that letting a third party layer of software come between the platform and the developer ultimately results in sub-standard apps and hinders the enhancement and progress of the platform. If developers grow dependent on third party development libraries and tools, they can only take advantage of platform enhancements if and when the third party chooses to adopt the new features. We cannot be at the mercy of a third party deciding if and when they will make our enhancements available to our developers.</em></p>
<p><em>“This becomes even worse if the third party is supplying a cross platform development tool. The third party may not adopt enhancements from one platform unless they are available on all of their supported platforms. Hence developers only have access to the lowest common denominator set of features. Again, we cannot accept an outcome where developers are blocked from using our innovations and enhancements because they are not available on our competitor’s platforms.”</em></p>
<p><small>Jobs, Steve. &#8220;<a title="Thoughts on Flash" href="http://www.apple.com/hotnews/thoughts-on-flash">Thoughts on Flash.</a>&#8221; Apple. Apple Inc., Apr. 2010. Web. 22 Nov. 2011.</small></p>
</div>
<p>&nbsp;</p>
<p>As you probably noticed, this post was from April of 2010. Yeah, that&#8217;s over a year and a half ago. And guess what? Adobe <b><i>still</i></b> doesn&#8217;t have it right. They&#8217;re close. But not there. And with the news of Adobe dropping mobile support for Flash Player a couple weeks ago, I&#8217;m guessing they never will be there. They may try to really hone in on the mobile application side, rather than just the Flash Player plugin for mobile, and they may get close. But like Jobs eluded to, Adobe holds all of its developers at the mercy of when they choose to adopt new features, whereas developing a mobile application natively gives immediate access to the full spectrum of features. </p>
<p>Don&#8217;t get me wrong. I&#8217;m not completely agreeing with the Flash haters out there who think that all Flash needs to go away&mdash;there is definitely still a time and place for Flash on the web. I&#8217;m just agreeing that Adobe needs to realize what their strengths are, and really concentrate on them rather than trying to get a foot into every single realm and telling developers that the Adobe solution will change their lives and work seamlessly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/dropping-the-ball-on-mobile-application-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Correcting the Flash Builder 4.5 Mobile TextInputSkin Component</title>
		<link>http://www.hesslerdesign.com/blog/flash/correcting-the-flash-builder-4-5-mobile-textinputskin-component/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/correcting-the-flash-builder-4-5-mobile-textinputskin-component/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 05:36:23 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[flash builder]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=749</guid>
		<description><![CDATA[I&#8217;ve been working on a mobile application in the recently released Flash Builder 4.5, which has support for exporting native apps for iOS and Android. While the engineering is largely sound and well done (with the exception of some big-name missing components from the &#8220;mobile-optimized&#8221; list, such as ComboBox), there are definitely a few glitches [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a mobile application in the recently released Flash Builder 4.5, which has support for exporting native apps for iOS and Android. While the engineering is largely sound and well done (with the exception of some big-name missing components from the &#8220;mobile-optimized&#8221; list, such as ComboBox), there are definitely a few glitches that I&#8217;ve encountered thus far in my experience with it. One such glitch is in the TextInput component.</p>
<p><span id="more-749"></span></p>
<h4>The Glitch</h4>
<p>In the mobile app that I&#8217;ve been working on, the design calls for the text input label to be placed &#8220;inside&#8221; of the text input field, on the left side. As such, I needed to add left padding to the TextInput component, so the text field wouldn&#8217;t overlap the label, which was sitting behind the TextInput control. So I set up my code to include the appropriate padding, and tested the result. When viewing the application, it looked just like it should, with the label positioned &#8220;inside&#8221; the TextInput component.</p>
<p><img src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/11/flash_builder_mobile_app_input_fields_blank.gif" alt="" title="flash_builder_mobile_app_input_fields_blank" width="480" height="191" class="aligncenter size-full wp-image-768" style="border:1px solid #dadada;" /></p>
<p>&nbsp;</p>
<p>However, when I started typing a value into the fields, that&#8217;s when I saw the glitch:</p>
<p><img src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/11/flash_builder_mobile_app_input_fields_glitch.gif" alt="" title="flash_builder_mobile_app_input_fields_glitch" width="480" height="191" class="aligncenter size-full wp-image-766" style="border:1px solid #dadada;" /></p>
<p>The problem was this: When typing in your text into the field, and the text goes longer than the width of the visible width of the text field inside of the component, you completely lose the cursor and can&#8217;t see the text you&#8217;re entering. That is, until your text width is as long as or greater than the width of the TextInput component. Then, your text suddenly shifts, with the text field taking up 100% of the width of the TextInput component. So naturally, I let out a huge sigh and asked, &#8220;What happened to my left padding? Did I do something wrong?&#8221;</p>
<p>The answer to my question is this: The padding never got incorporated into the component correctly. And no, I didn&#8217;t do anything wrong. Adobe did.</p>
<h4>The Solution</h4>
<p>In my wrestling with how to fix this issue, I copied over the default TextInputSkin file (spark.skins.mobile.TextInputSkin) and put it into my project files. Then I opened it up and started investigating. Here&#8217;s what I found:</p>
<p>In the &#8220;layoutContents&#8221; method, I found a very big issue with the logic. And while it may seem like a small, innocent issue, it looms large when trying to add padding of any sort to the component. The issue is caused by 3 errors in the code of this function.</p>
<p><strong>Error #1</strong></p>
<div style="padding:12px; background:#fff; border:1px solid #dadada;">
<code style="margin-left: 20px;">textDisplay.leftMargin = paddingLeft;</code><br />
<code style="margin-left: 20px;">textDisplay.rightMargin = paddingRight;</code>
</div>
<p>These two lines are worthless. Why? It doesn&#8217;t solve any problems. It creates the skip in the text inputting described above, specifically when paired with the other two errors below. So, I commented these two lines out.</p>
<p>&nbsp;</p>
<p><strong>Error #2</strong></p>
<div style="padding:12px; background:#fff; border:1px solid #dadada;">
<code style="margin-left: 20px;">setElementSize(textDisplay, unscaledWidth, adjustedTextHeight);</code>
</div>
<p>This error is just plain and simple wrong. There&#8217;s a variable for &#8220;unscaledWidth&#8221;, which is the width of the ENTIRE component, NOT the width of the textDisplay (i.e. text field) after having padding taken into consideration. There&#8217;s actually a variable called &#8220;unscaledTextWidth&#8221; in the code, which is the value that SHOULD be used in this instance of &#8220;setElementSize&#8221;, because the textDisplay should have a width that has the left and right padding taken into consideration.  So, I changed this line to be:</p>
<div style="padding:12px; background:#fff; border:1px solid #dadada;">
<code style="margin-left: 20px;">setElementSize(textDisplay, unscaledTextWidth, adjustedTextHeight);</code>
</div>
<p>&nbsp;</p>
<p><strong>Error #3</strong></p>
<div style="padding:12px; background:#fff; border:1px solid #dadada;">
<code style="margin-left: 20px;">setElementPosition(textDisplay, 0, textY);</code>
</div>
<p>This error, like the last, is also just plain wrong. The 2nd argument for the &#8220;setElementPosition&#8221; method is the X value, which you&#8217;ll notice is HARD-CODED to &#8220;0&#8243;. This means that no matter what your left padding value is, the textDisplay will ALWAYS be set to the left side of the component. The x value should be based on the value of the left padding. So, I changed this line to be:</p>
<div style="padding:12px; background:#fff; border:1px solid #dadada;">
<code style="margin-left: 20px;">setElementPosition(textDisplay, paddingLeft, textY);</code>
</div>
<h4>Conclusion</h4>
<p>With the 3 errors above fixed, my TextInput component was finally working as intended, with the correct padding values, no intermittent skipping, and no random resizing of the text field inside of the component. Rather, like any other good text input field out there, it only displays the text width it should, while hiding the rest.</p>
<p><img src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/11/flash_builder_mobile_app_input_fields_fixed.gif" alt="" title="flash_builder_mobile_app_input_fields_fixed" width="480" height="191" class="aligncenter size-full wp-image-773" style="border:1px solid #dadada;" /></p>
<p>&nbsp;</p>
<p>So if you find yourself questioning why something isn&#8217;t working as intended, take a few minutes (or hours, in some unfortunate instances) and look into the class/component/code you&#8217;re working with. Not only will you get a better understanding of how everything is set up, but you might just find another spot where the software engineers overlooked something and made an error.</p>
<p>Until next time, happy coding!</p>
<h4>Postscript</h4>
<p>Even though I am not a fan of how Adobe laid out this TextInputSkin, I must admit that I can see how/why it was done the way it was. There aren&#8217;t many times where a mobile application would call for a situation like the one I had. Chances are, Adobe&#8217;s quality assurance and testing didn&#8217;t think to include such a circumstance. After all, most mobile application components like text input boxes are set up to take up 100% of the screen (or close to it) to optimize hit area and visual space. So, giving them the benefit of the doubt, I can&#8217;t say I&#8217;m mad at Adobe for how they put things together. But I stick to my statement that if something isn&#8217;t working as intended, take some time to look into the code behind the scenes. You just might find something in need of fixing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/correcting-the-flash-builder-4-5-mobile-textinputskin-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FileLoader: A Flash Preloader &amp; Container File (with Cache Buster Option)</title>
		<link>http://www.hesslerdesign.com/blog/flash/fileloader-a-flash-preloader-container-file-with-cache-buster-option/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/fileloader-a-flash-preloader-container-file-with-cache-buster-option/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 05:06:04 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=711</guid>
		<description><![CDATA[Recently, I had a client whose server had its own cache that only cleared once a day, which ended up posing problems for updating content, as the server cache would either needed to be flushed, or we&#8217;d just have to wait it out and wait for the cache to clear on its own.  The content [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had a client whose server had its own cache that only cleared once a day, which ended up posing problems for updating content, as the server cache would either needed to be flushed, or we&#8217;d just have to wait it out and wait for the cache to clear on its own.  The content I was working on was a Flash file, so rather than having to flush the server cache every time I made an update, I came up with another solution for the Flash file.</p>
<p>The solution was to make a &#8220;container&#8221; SWF file that would load in the actual content for the page.  This was nice because the container ended up also acting as a preloader for the main content.  All I had to do in the container file was to append a query string to the end of the content to load in (i.e. &#8220;photo.jpg?id=12345678&#8243;), which effectively acted as a &#8220;cache buster&#8221; that would make the browser and server think it was loading a new file each time the page was loaded.</p>
<p>The result was this little nugget of Flash goodness: <strong>FileLoader</strong>.</p>
<p>I polished up the container file I made in my solution above, adding in a couple of customizable variables, and am making it freely available for download.</p>
<p><span id="more-711"></span></p>
<h4>Version Information:</h4>
<ul>
<li><strong>Version:</strong> 1.0</li>
<li><strong>Release Date:</strong> 1/12/11</li>
</ul>
<h4>Download:</h4>
<p>Like what you see? Want to use FileLoader with your own Flash projects? Click the button below to download the most recent version of FileLoader, including a demo file with full instructions.</p>
<div style="margin-top: 9px;"><a href="http://www.hesslerdesign.com/downloads/fileloader/FileLoader.zip"><img class="aligncenter size-full wp-image-426" title="Download FileLoader" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/btn_downloadFileLoader.png" alt="Download FileLoader" width="166" height="29" /></a></div>
<h4>License:</h4>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="top"><a rel="license" href="http://creativecommons.org/licenses/by/3.0/us/" target="_blank"><img style="border-width: 0; margin-top: 3px;" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" alt="Creative Commons License" /></a></td>
<td valign="top">
<p style="float: left; margin-top: 0px;">FileLoader is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>, and is free to use. Links back to <strong>hesslerdesign.com</strong> are always appreciated. Permissions beyond the scope of this license may be available by submitting a <a rel="cc:morePermissions" href="http://www.hesslerdesign.com/contact/">Contact Request</a>.</p>
</td>
</tr>
</tbody>
</table>
<h4>Description:</h4>
<p>FileLoader is a simple, lightweight, easy-to-implement FLA/SWF file that acts as a preloader and container for files. It is made to load a specified URL, can enable &#8220;cache busting&#8221;, and provides the ability to change the hex color of the preloader and text. It can load any type of file that the built-in Loader class loads (SWF, JPG, PNG, GIF).</p>
<h4>Example:</h4>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="534" height="442" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/fileLoaderDemo.swf" /><embed type="application/x-shockwave-flash" width="534" height="442" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/fileLoaderDemo.swf"></embed></object></p>
<h4>Instructions:</h4>
<p>To use this file, simply update any/all of the customizable variables located on the aptly-named &#8220;Customizable Variables&#8221; layer (in .fla file). These variables include:</p>
<ol>
<li><strong>contentURL (String):</strong> URL path of the content you wish to load into FileLoader. (Default = &#8220;&#8221;)</li>
<li><strong>tintHex (uint):</strong> Hex value to tint the preloader and error message. (Default = &#8220;0&#215;000000&#8243;)</li>
<li><strong>cacheBuster (Boolean):</strong> Enables/Disables &#8220;cache busting&#8221; on your content. (Default = &#8220;false&#8221;)</li>
</ol>
<p>Once the variables are updated, just export the SWF and it&#8217;s ready to be embedded into your HTML page for the web.</p>
<h4>Notes:</h4>
<ol>
<li>FileLoader is set up to resize itself to 100% of the stage width and height, making it flexible to be used at any size. This means you don&#8217;t have to worry about changing the dimensions of the file, and when embedding this file into your HTML page, you can specify any width and height you wish. The Preloader and Load Error (if applicable) will automatically center themselves to the stage. The content, however, has no special positioning logic, and will be placed at the (0,0) point of the stage. Thus, it is intended that this file will be embedded at the exact size of the content you&#8217;re loading into it, as this file is only intended to be a preloader and container for the contents of one file.</li>
<li>The Preloader and Load Error elements (where applicable) are automatically added to and removed from the file when needed. Your content will automatically be placed into the file when it&#8217;s loaded, and be the only item on the stage at that point. You don&#8217;t have to do anything special to get your content to display other than specifying a valid content URL.</li>
<li>When you&#8217;re ready to post the files to your website, just make sure you upload this file along with the content it loads. Also, <strong><span style="text-decoration: underline;">make sure your pathing is set up appropriately for the content URL</span></strong> or your content may not load correctly.</li>
<li>If you update or change any of the MovieClips in the library, or update, append or change any of the code in the main Actions layer, this file may break. If you know what you&#8217;re doing with Flash and ActionScript, you shouldn&#8217;t have any problem figuring out how things work and can be edited. If you&#8217;re a beginner or novice, you may have a harder time editing. With that said, edit the non-customizable elements at your own risk.</li>
<li>If the &#8220;cacheBuster&#8221; variable is set to &#8220;true&#8221;, a random 8-digit ID will be appended as a query string to the &#8220;contentURL&#8221; variable (i.e. &#8220;<em>photo.jpg?id=12345678</em>&#8220;). When the cache buster is enabled, it will force the FileLoader to load a fresh version of the content URL each time it is loaded. This is helpful if you are posting your Flash content on a server with its own cache settings that would result in updated content not being immediately visible until the server cache clears. If this variable is set to &#8220;false&#8221;, no ID will be appended to the content URL, and the loaded content will be cached as normal.</li>
<li><strong><span style="text-decoration: underline;">Important:</span></strong> Use the cache busting sparingly and only when necessary, as it may end up bogging down the server with unnecessary calls to the server to reload the content.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/fileloader-a-flash-preloader-container-file-with-cache-buster-option/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Websites Giving Flash a Bad Name</title>
		<link>http://www.hesslerdesign.com/blog/user-experience-2/websites-giving-flash-a-bad-name/</link>
		<comments>http://www.hesslerdesign.com/blog/user-experience-2/websites-giving-flash-a-bad-name/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 03:49:14 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[User Experience]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[websites]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=700</guid>
		<description><![CDATA[We&#8217;ve all seen them.  Horribly designed, heavy, busy, and &#8220;flashy&#8221;.  Yep, you guessed it.  Bad Flash websites.  But beyond that, I firmly believe there&#8217;s another obvious reason why people (like the folks at Apple, for instance) don&#8217;t like Flash.  And as much as I may hate to say it, being a web developer who uses [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen them.  Horribly designed, heavy, busy, and &#8220;flashy&#8221;.  Yep, you guessed it.  Bad Flash websites.  But beyond that, I firmly believe there&#8217;s another obvious reason why people (like the folks at Apple, for instance) don&#8217;t like Flash.  And as much as I may hate to say it, being a web developer who uses Flash in my digital tool belt, I&#8217;m starting to lean the same way.  Here&#8217;s a huge reason why&#8230;</p>
<p>Yahoo!  Heard of that website?  Thought so.  It used to be my home page.  That is, until the Flash ads literally started to hamper my user experience and demand my attention not only to see the stupid thing, but to figure out where I needed to click to close the darn thing.  I&#8217;ve since boycotted Yahoo! because of the repeatedly poor user experiences I had.  I mean seriously, check out this screenshot I took of the Yahoo! start page and see if you notice what may have annoyed me:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-701" title="Yahoo Home Page" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/12/yahoo_home_page.jpg" alt="Yahoo Home Page Screenshot" width="543" height="431" /></p>
<p style="text-align: left;">Yep, you guessed it.  That innocent little ad in the right side column (which started out in its own box, by the way) expanded itself &#8212; on its own &#8212; multiple times before settling into its home, where it should have been in the first place.  And when it expands, it overlays the main content of the page.  So if you click just a split second too late, you&#8217;re getting passed off to the ad&#8217;s site like a proverbial peace pipe, becoming another statistic in their &#8220;click-through rate&#8221; column, and furthering the spread of expandable ads, because the stats are saying they&#8217;re more effective due to the increase in click-rate.</p>
<p style="text-align: left;">Call me old fashioned, but that sort of in-your-face advertising represents a key problem with advertising &#8212; specifically with what is done with Flash.</p>
<p style="text-align: left;">Somewhere in the world, some Flash developer worked on this ad.  And this is happening all over the place.  Maybe the Flash developers are thinking it&#8217;s cool, and a good idea.  Maybe they are doing it because The Man is telling them they have to in order to get their paycheck.  Or because the client is paying them handsomely and for that, they just don&#8217;t care.</p>
<p style="text-align: left;">Whatever the reason may be, here&#8217;s my humble opinion:  Any Flash developer who works on ads like these and doesn&#8217;t feel remorse for the end user is not a true web developer.  In my mind, they simply fall into the category of someone who knows how to use Flash as a program, not as a tool to use  to truly create a good user experience with it when the situation calls for it.  It&#8217;s like someone who picks up Photoshop (or PS Elements) and thinks they&#8217;re a graphic designer just because they own the software and know how to crop a picture or auto-adjust levels.  I don&#8217;t claim to be an auto mechanic just because I&#8217;ve changed my own oil and own a socket wrench.  Or a heating and cooling expert just because I changed the air filter on my furnace.  Or a doctor because I own a thermometer and can gauge when I&#8217;m running a fever.</p>
<p style="text-align: left;">Simply put, I am seriously starting to dislike and even boycott websites with poor user experiences.  And like I said, because of my Yahoo! experience, I have honestly stopped visiting their site as my source for news and email.  I&#8217;d much rather get news from somewhere like Google, where clean and simple hierarchical text and images are used, and intuitive user interface design is present.  It&#8217;s clean, easy to read, and unassuming, letting me get to where I need faster and easier.</p>
<p style="text-align: left;">Until next time, happy (and better, more intelligent, less obtrusive) coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/user-experience-2/websites-giving-flash-a-bad-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Gradient Fill on Dynamic Text in Flash ActionScript 3.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 18:22:20 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[text format]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=667</guid>
		<description><![CDATA[The other day, I had a revelation. It was a moment a lot like the Microsoft commercials, where I pictured myself slightly better looking (3 inches taller, perfect hair, and more muscular), coming to a moment of self-realization&#8230;. Or something like that. Maybe you’ve already figured this out, maybe not. Either way, I think it’s [...]]]></description>
			<content:encoded><![CDATA[<p>The other day, I had a revelation. It was a moment a lot like the Microsoft commercials, where I pictured myself slightly better looking (3 inches taller, perfect hair, and more muscular), coming to a moment of self-realization&#8230;. Or something like that.  Maybe you’ve already figured this out, maybe not.  Either way, I think it’s pretty sweet.</p>
<p>Here’s what my realization entailed:</p>
<p>As some of you may know, I’m always a big fan of keeping live text — be it static or dynamic — in Flash files, so that when I or anyone needs to go back in and make an update, it can be done w/o opening a Photoshop file, slicing and dicing image(s), and importing them into Flash.  Not only is it easier, but it&#8217;s a tremendous help in keeping file size down.</p>
<p>One aspect that is sometimes difficult is when a design calls for an effect on text, such as a gradient.  In Flash, we’re all probably aware that you can create a static text field and a shape (such as a gradient box), set the text field on the layer above said shape, and right-click the text layer to set it as a mask over the shape.  But here&#8217;s where my realization came…</p>
<div style="margin: 18px 0px; text-align: center;"><em><strong><span style="font-size: 150%; line-height: 130%;">“Why stop there?  This same effect can be done with pure ActionScript.”</span></strong></em></div>
<p>It&#8217;s very true — this same effect can be done with pure ActionScript, for more dynamic scenarios&#8230; or if you&#8217;re one of those people who hate the stage with a passion.  All I’d need to do in the code is create a text field and a gradient box, layer them appropriately, and set the text as the mask on the gradient box.  And, since you can embed fonts in Flash (see the previous post about <a title="Embedding Fonts Using ActionScript 3.0" href="http://www.hesslerdesign.com/blog/flash/embedding-fonts-using-actionscript-3-0/" target="_blank">Embedding Fonts Using ActionScript 3.0</a>), it can be done with any crazy display font that a design calls for (Immi 505 in the example below).</p>
<p>With that in mind, I put together a little demo to prove to myself (and you) that it was as easy as I thought it would be.  The demo has an input text field that you can use to change and update the text &#8212; which happens on the fly each time the input field is updated (so you know it&#8217;s truly live and dynamic, and not slight of hand).  So go ahead and play around with it.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="546" height="124" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/dynamicGradientText.swf" /><embed type="application/x-shockwave-flash" width="546" height="124" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/dynamicGradientText.swf"></embed></object></p>
<div style="margin-bottom:24px;"><small><em>Note: In this demo, the text field is set to single line with 28 character max, and its width is currently hard-coded.   This is all for the sake of the fact that it’s a demo, and to keep things neat and tidy.  It’s easy to base the width of the text field and gradient box to be based on the &#8220;textWidth&#8221; property of the text field, for even more coding nirvana.  And with only a little more effort (duplicating your gradient box and repositioning its y position based on the line height of the text field), you can do multiline text with the same gradient on each line, though it would definitely take some more tweaking and massaging based on the individual font, line height, font size, etc.</em></small></div>
<p>So there you have it.  Dynamic text with a gradient fill effect.  Easy peasy, eh?</p>
<p>Until next time, happy coding!</p>
<h4>Download</h4>
<p>What&#8217;s that, you say? You want to see the source code to make this work? Well, ask and ye shall receive. Just click the button below to download the source FLA and AS file for this demo.</p>
<div style="margin-top:24px;"><a href="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/11/DynamicGradientText.zip"><img class="aligncenter size-full wp-image-426" title="Download Sample" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/btn_downloadSample.png" alt="Download Sample" width="150" height="29" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/creating-a-gradient-fill-on-dynamic-text-in-flash-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Clean Up Your Flash Applications with the Help of Math</title>
		<link>http://www.hesslerdesign.com/blog/flash/clean-up-your-flash-applications-with-the-help-of-math/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/clean-up-your-flash-applications-with-the-help-of-math/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 23:21:25 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[user experience]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=648</guid>
		<description><![CDATA[We&#8217;ve all seen it before. Someone builds a well-intentioned Flash website that will wow the masses, but that ends up looking sub-par because of mis-placed, mis-sized, or otherwise unfortunate visual assets. It&#8217;s easy to do — you put together a design, draw out your shapes, do some resizing with a Transform tool to get things [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen it before. Someone builds a well-intentioned Flash website that will wow the masses, but that ends up looking sub-par because of mis-placed, mis-sized, or otherwise unfortunate visual assets.  It&#8217;s easy to do — you put together a design, draw out your shapes, do some resizing with a Transform tool to get things &#8220;perfect&#8221;, and in the process, you inevitably create fuzzy lines.  It&#8217;s not all your fault.  Blame it on Photoshop or Flash for allowing smaller-than-pixel increments — doesn&#8217;t matter to me where you place the blame.  But at the end of the day, one of the MUST DO items when putting together any website is to ensure that your vertical and horizontal lines are crisp and exact — unless there&#8217;s good reason why to do otherwise.</p>
<p>Lucky for you, Flash comes well-equipped with providing tools for developers to use when coding their Flash applications.  My three most-used Flash methods for clean lines and exact placement are listed below, and are all part of Flash&#8217;s Math class.  If you use them, you&#8217;ll be sure clean up the lines and sizes of your site in no time.  (It may not help poorly-drawn shapes that you draw by hand, but for dynamically-drawn, code-generated items, or code-based asset placement, it&#8217;s golden.)</p>
<h4>A Few of My Favorites</h4>
<p><strong><code>Math.ceil()</code></strong><br />
This function returns the ceiling of the specified number or expression, which equates to the closest integer that is greater than or equal to the number.</p>
<div style="margin-left: 20px; margin-bottom: 32px;"><em>Example:</em><br />
<code><span style="color: #0000ff;">var</span> myValue:<span style="color: #0000ff;">Number</span> = <span style="color: #0000ff;">Math.ceil</span>(4.385); <span style="color: #999999;">// Returns 5</span></code></div>
<p><strong><code>Math.floor()</code></strong><br />
This function returns the floor of the specified number or expression, which equates to the closest integer that is less than or equal to the number.</p>
<div style="margin-left: 20px; margin-bottom: 32px;"><em>Example:</em><br />
<code><span style="color: #0000ff;">var</span> myValue:<span style="color: #0000ff;">Number</span> = <span style="color: #0000ff;">Math.floor</span>(4.385); <span style="color: #999999;">// Returns 4</span></code></div>
<p><strong><code>Math.round()</code></strong><br />
This function rounds the value of the passed-in parameter to the nearest closest integer. If the passed-in value is exactly in the middle, it rounds up.</p>
<div style="margin-left: 20px; margin-bottom: 32px;"><em>Examples:</em><br />
<code><span style="color: #0000ff;">var</span> myValue:<span style="color: #0000ff;">Number</span> = <span style="color: #0000ff;">Math.round</span>(4.385); <span style="color: #999999;">// Returns 4</span></code><br />
<code><span style="color: #0000ff;">var</span> myMiddleValue:<span style="color: #0000ff;">Number</span> = <span style="color: #0000ff;">Math.round</span>(4.5); <span style="color: #999999;">// Returns 5</span></code></div>
<p><span id="more-648"></span></p>
<h4><span style="color: #999999;"><span style="color: #000000;">How and When to Use the Math Functions</span></span></h4>
<p>Let&#8217;s say you have a square MovieClip that&#8217;s sitting on your stage with an <code>x</code> coordinates of 133.  You want to tween it with ActionScript to a point 50% of the way to the left edge of your application from it&#8217;s original point of 133.  You&#8217;ll need to have the <code>x</code> coordinate change for the move, obviously.  But if you simply figure out what point to tween to without somehow finding the nearest integer value, you&#8217;ll be left with a non-integer value (66.5), and your horizontal and vertical lines will get fuzzy.  However, if you use the <code>Math.round()</code> method, for instance, you&#8217;ll get an integer value (67), which will keep your horizontal and vertical lines crisp and clean.</p>
<p>In the example SWF below, there are two square MovieClips, both placed at an <code>x</code> coordinate of 133, as in the example above.  The top one does <em>not</em> use the Math class to get the integer-based pixel value it will end on.  The bottom one, on the other hand, <strong><em>does</em></strong> use the Math class, and rounds the target value to the nearest integer, thus resulting in a final <code>x</code> coordinate that is an integer.  Click on each box to tween it, and notice the end result of the boxes side by side.  You&#8217;ll quite obviously notice the top box having fuzzy edges when compared the the clean lines of the bottom box.</p>
<p style="text-align:center;">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="260" height="200" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/integerTweens.swf" /><embed type="application/x-shockwave-flash" width="260" height="200" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/11/integerTweens.swf"></embed></object>
</p>
<h4>Know, Love, and Understand Integers</h4>
<p>The important part to note about all three of these methods is that they all calculate the closest &#8220;integer&#8221; — or whole number.  This is immensely helpful, because if you base your <code>width</code>, <code>height</code>, <code>x</code>, or <code>y</code> values on any of these methods, you&#8217;ll always get back a whole-pixel value, which will give you the crisp edges that we all know and love.  With that said, there is one important exception….</p>
<p>Even though these methods return integers, there is still one more &#8220;gotcha&#8221; that you&#8217;ll need to keep in mind when developing your Flash application.  If you have a MovieClip of a square shape, for instance, and you have it centered to the registration point of the MovieClip, you may still get fuzzy pixels.  How, you ask?  If your square has a width and/or height whose value is an odd number (57, for example), its <code>x</code> and <code>y</code> coordinates will be half-pixels within the MovieClip (-28.5, -28.5 for a width of 57).  And if you place this MovieClip on the stage and put it at coordinates whose values are integers, the edges will be fuzzy, because of the coordinates of the object within the MovieClip.</p>
<p>To combat this, there are a couple of options:</p>
<ul>
<li>If you center your object(s) in your MovieClips (or other display objects), make sure they have dimensions that are even numbers.  If this isn&#8217;t doable, at least make the <code>x</code> and <code>y</code> coordinates integer values, even if it means your assets won&#8217;t be &#8220;exactly&#8221; centered in the MovieClip.</li>
<li>Instead of centering your object(s) in your MovieClips, use corner-based orientation, so, for example, your object(s) will have an <code>x</code> and <code>y</code> value of 0.  This way, you&#8217;ll be guaranteed to have crisp lines when the MovieClip is placed at coordinates whose values are integers.</li>
</ul>
<h4>Other Best Practices for Clean Lines</h4>
<ul>
<li>When drawing shapes with horizontal and/or vertical lines in Flash, make sure that the <code>x</code> and <code>y</code> coordinates are integer values in your Properties panel.  Also, make sure the <code>width</code> and <code>height</code> are also integer values.  Every so often, Flash will want to add/subtract a random 0.05 from your typed-in values, so you may need to re-type in a value now and again.</li>
<li>If you&#8217;re nudging objects around on your stage, turn on &#8220;Snap to Pixels&#8221;.  To do this, select the &#8220;View&#8221; menu, and select &#8220;Snapping &gt; Snap to Pixels&#8221;.  Doing this will always snap your objects to integer (pixel) values.</li>
</ul>
<h4>Wrapping Up</h4>
<p>So there you have it.  With a little careful planning and knowhow, and with a little help from the Math class, you can ensure your Flash applications have vertical and horizontal lines that are crisp and exact, creating a much stronger, cleaner design.</p>
<p>Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/clean-up-your-flash-applications-with-the-help-of-math/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting Raw Numbers with Commas</title>
		<link>http://www.hesslerdesign.com/blog/tutorials/formatting-raw-numbers-with-commas/</link>
		<comments>http://www.hesslerdesign.com/blog/tutorials/formatting-raw-numbers-with-commas/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 14:48:44 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=637</guid>
		<description><![CDATA[I&#8217;ve worked on a number of Flash projects where I&#8217;ve needed to convert a raw number into a correctly comma-formatted string for display.  Doing this is a relatively simple process, but since I found myself repeating the same chunk of code in multiple projects, I ended up creating a function that I could reuse over [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve worked on a number of Flash projects where I&#8217;ve needed to convert a raw number into a correctly comma-formatted string for display.  Doing this is a relatively simple process, but since I found myself repeating the same chunk of code in multiple projects, I ended up creating a function that I could reuse over and over again. And the nice thing about this chunk of code is that, with a few language-specific modifications, you can use it as JavaScript, PHP, etc.</p>
<p><code><span style="color: #999999;">// This variable gets set as 1,234,567,890</span><br />
<span style="color: #0000ff;">var</span> commaFormattedNumber:<span style="color: #0000ff;">String</span> = formatWithCommas(<span style="color: #009900;">"1234567890"</span>); </code></p>
<p><code><span style="color: #0000ff;">function</span> formatWithCommas(pNum_str:<span style="color: #0000ff;">String</span>):<span style="color: #0000ff;">String</span> {<br />
&nbsp; &nbsp;<span style="color: #0000ff;">var</span> lReturn_str:String = <span style="color: #009900;">""</span>;<br />
&nbsp; &nbsp;<span style="color: #0000ff;">var</span> lStringAsArray_arr:Array = pNum_str.split(<span style="color: #009900;">""</span>);<br />
&nbsp; &nbsp;<span style="color: #0000ff;">var</span> commaCounter_num:Number = 1;<br />
&nbsp; &nbsp;for (<span style="color: #0000ff;">var</span> i=lStringAsArray_arr.<span style="color: #0000ff;">length</span>-1; i&gt;=0; i--) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;lReturn_str = lStringAsArray_arr[i] + lReturn_str;<br />
&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0000ff;">if</span> ((commaCounter_num == 3) &amp;&amp; (i != 0)) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;lReturn_str = "," + lReturn_str;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;commaCounter_num = 1;<br />
&nbsp; &nbsp;&nbsp; &nbsp;} <span style="color: #0000ff;">else</span> {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;commaCounter_num++;<br />
&nbsp; &nbsp;&nbsp; &nbsp;}<br />
&nbsp; &nbsp;}<br />
&nbsp; &nbsp;<span style="color: #0000ff;">return</span> lReturn_str;<br />
}</code></p>
<h4>Notes:</h4>
<ul>
<li>In our example, we pass in 1 String value into the function, and it returns a String.</li>
<li>Inside of the function, we split the passed-in string into an Array, then we loop through the array backwards, adding the number in each array slot each time through the loop.</li>
<li>While looping through the array, notice that we have the variable <code>commaCounter_num</code>, which keeps track of which slots to also add in a comma. The conditional logic checks if the <code>commaCounter_num</code> is up to 3 and if the value of <code>i</code> is NOT zero. If both of these are true, we add in a comma and continue on. We must add the check of ensuring that <code>i</code> is not zero, so we don&#8217;t get a 6-digit number, for example, that ends up being returned with a comma at the very beginning of the string.</li>
</ul>
<p>So there you have it.  A nice little chunk of code you can use to format a number into a correctly comma-formatted string. Not a whole lot to it, but still a nice reference function to have for future use.</p>
<p>Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/tutorials/formatting-raw-numbers-with-commas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

