<?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 &#187; actionscript 3</title>
	<atom:link href="http://www.hesslerdesign.com/blog/tag/actionscript-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hesslerdesign.com/blog</link>
	<description>Smart Developers = Smart Websites</description>
	<lastBuildDate>Thu, 26 Jan 2012 23:00:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>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>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>
		<item>
		<title>Confetti Class for ActionScript 3.0</title>
		<link>http://www.hesslerdesign.com/blog/flash/confetti-class-for-actionscript-3-0/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/confetti-class-for-actionscript-3-0/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 18:30:37 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[classes]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=622</guid>
		<description><![CDATA[On a recent project I was working on, I had to create animated snowfall, to give the effect of a winter wonderland. Rather than doing timeline animation (WAY too much detail to do with individual snowflakes by hand), I made a class that displays/generates the effect of random snowfall. And rather than just making the [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project I was working on, I had to create animated snowfall, to give the effect of a winter wonderland.  Rather than doing timeline animation (WAY too much detail to do with individual snowflakes by hand), I made a class that displays/generates the effect of random snowfall.  And rather than just making the class specific to snowflakes, I made it a generic and flexible Confetti class to be used in multiple ways.</p>
<p>A few notes about the class, its flexibility, and it’s use:</p>
<ul>
<li>Overall, the class automatically assigns random X coordinates, fall times, delays, scale, alpha, rotation, and tint (if colors are specified) for the effect of true randomness and depth of field.</li>
<li>To import, instantiate, and start a batch of confetti in the file, only 4 lines of code are needed.</li>
<li>There is a public “start()” method for the class, rather than having the class auto-start (though the demo below does auto-start, but that is through the parent file, not the class).  This is done in an effort to save in performance.  There are also public methods for “stop()”, “clear()”, and “remove()”, done in an effort to to be able to phase out the confetti (stop), clear all current instances of individual confetti pieces (clear), or stop and clear out all confetti pieces (remove).</li>
<li>The class is set up to pass in an Object as the parameter when creating your Confetti object, which takes up to 6 optional attributes: width, height, colors, maxPieces, symbol, and speed.  If any or all of these are not defined, default values will be used.  Through much time and testing, calculations were solidified to make for realistic default settings.</li>
<li>The class allows for passing in a custom symbol to use, rather than using the auto-generated one. In the demo below, all &#8220;shape modes&#8221; other than &#8220;Auto&#8221; are instances of MovieClips from the Library, set to export to ActionScript. These custom MovieClip symbols can have multiple frames, too.  If a MovieClip symbol has multiple frames, the class will randomly assign a frame to show for each individual piece.</li>
</ul>
<p>With that all said, here&#8217;s a demo of the Confetti class.  And in response to the request, the class and a sample FLA file are available for download (see link below the demo).  Feel free to toy around with it, change the settings, and have fun with it.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="548" height="444" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0"><param name="src" value="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/09/confettiDemo_blog.swf" /><embed type="application/x-shockwave-flash" width="548" height="444" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2010/09/confettiDemo_blog.swf"></embed></object></p>
<div style="margin-top:24px;"><a href="http://www.hesslerdesign.com/downloads/confetti/Confetti_Sample.zip"><img class="aligncenter size-full wp-image-426" title="Download Confetti Sample" src="http://www.hesslerdesign.com/blog/wp-content/uploads/2011/01/btn_downloadSample.png" alt="Download Confetti Sample" width="150" height="29" /></a></div>
<p>Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/confetti-class-for-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Converting Strings to Numbers in Adobe Flash</title>
		<link>http://www.hesslerdesign.com/blog/flash/converting-strings-to-numbers-in-adobe-flash/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/converting-strings-to-numbers-in-adobe-flash/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 14:47:26 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[Numbers]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=610</guid>
		<description><![CDATA[I&#8217;ve had a few Flash projects I&#8217;ve worked on where I will find myself needing to import data from an external source, and I end up getting back String values that I will need to convert into Numbers.  While the actual process of converting a String to a Number is relatively simple (assuming your String [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a few Flash projects I&#8217;ve worked on where I will find myself needing to import data from an external source, and I end up getting back String values that I will need to convert into Numbers.  While the actual process of converting a String to a Number is relatively simple (assuming your String value is numeric, that is), I went one step further and came up with a script block that I can use to convert Strings to Numbers, even if I get a comma-delimited String of multiple numbers.  Here&#8217;s the code block, with an explanation of key items below.</p>
<p><code><span style="color: #0000ff;">var</span> sampleString_str:<span style="color: #0000ff;">String</span> = <span style="color: #009900;">"1, 23, 4, 5, 67"</span>;<br />
<span style="color: #0000ff;">var</span> convertedNumbers_arr:<span style="color: #0000ff;">Array</span> = <span style="color: #0000ff;">new Array</span>();<br />
<span style="color: #0000ff;">var</span> sampleStringAsArray_arr:<span style="color: #0000ff;">Array</span> = convertToArray(sampleString_str);<br />
convertArrayValuesToNumbers(sampleStringAsArray_arr);<br />
<span style="color: #0000ff;">function</span> convertToArray(pValue_str:<span style="color: #0000ff;">String</span>):Array {<br />
&nbsp; &nbsp;pValue_str = pValue_str.<span style="color: #0000ff;">replace</span>(<span style="color: #009900;">/ /</span>g, <span style="color: #009900;">""</span>);<br />
&nbsp; &nbsp;<span style="color: #0000ff;">var</span> lArray_arr:<span style="color: #0000ff;">Array</span> = pValue_str.<span style="color: #0000ff;">split</span>(<span style="color: #009900;">/,/</span>);<br />
&nbsp; &nbsp;<span style="color: #0000ff;">return</span> lArray_arr;<br />
}<br />
<span style="color: #0000ff;">function</span> getNumber(pValue_str:<span style="color: #0000ff;">String</span>):<span style="color: #0000ff;">Number</span> {<br />
&nbsp; &nbsp;<span style="color: #0000ff;">return</span> <span style="color: #0000ff;">Number</span>(pValue_str);<br />
}<br />
<span style="color: #0000ff;">function</span> convertArrayValuesToNumbers(pArray_arr:<span style="color: #0000ff;">Array</span>):<span style="color: #0000ff;">void</span> {<br />
&nbsp; &nbsp;<span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">var</span> i=0; i&lt;pArray_arr.<span style="color: #0000ff;">length</span>; i++) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;convertedNumbers_arr[i] = getNumber(<span style="color: #0000ff;">String</span>(pArray_arr[i]));<br />
&nbsp; &nbsp;}<br />
}</code></p>
<h4>Notes:</h4>
<ul>
<li>In our example, the variable <code>sampleString_str</code> holds a sample String of comma-delimited number values. The empty array <code>convertedNumbers_arr</code> will hold each Number converted from sample String, once our functions start running. And the Array <code>sampleStringAsArray_arr</code> contains the individual String values of each item from <code>sampleString_str</code>.</li>
<li>In the function <code>convertToArray()</code>, we use <code>replace()</code> to clear out all spaces, if they exist, with the <code>g</code> (global) flag on regular expression so it will replace ALL, not just first instance of regular expression value. After space removal, we use the <code>split()</code> method to split the String into an Array at each instance of a comma. Once these run through, the function returns an Array, which we set equal to our variable <code>sampleStringAsArray_arr</code>.</li>
<li>In the function <code>convertArrayValuesToNumbers()</code>, we loop through the passed-in Array and assign each slot of <code>convertedNumbers_arr</code> to the Number value of the given array slot we are converting.</li>
<li>When all is said and done, the Array <code>convertedNumbers_arr</code> now holds actual Number values of each number from the original String, <code>sampleString_str</code>.</li>
</ul>
<p>Again, it doesn&#8217;t take much to convert a String to a Number, or even vice versa.  But with a few extra lines of code, we can take that to the next level and convert comma-delimited Strings to an Array of accompanying Number values that we can then use as true Numbers.</p>
<p>Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/converting-strings-to-numbers-in-adobe-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VideoMax Custom Flash Video Player Class Now Available!</title>
		<link>http://www.hesslerdesign.com/blog/flash/mediaplayer-custom-flash-video-player-class-now-available/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/mediaplayer-custom-flash-video-player-class-now-available/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 01:00:27 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=336</guid>
		<description><![CDATA[What is VideoMax? VideoMax is a very lightweight, fast, flexible, and easy-to-implement custom Flash video player class that can be used in any ActionScript 3.0 file. Some of the key highlights of the VideoMax class are: Lightweight: Importing the VideoMax class and creating an instance adds only 12kb to overall file weight. Compare that to [...]]]></description>
			<content:encoded><![CDATA[<h4>What is VideoMax?</h4>
<p>VideoMax is a very lightweight, fast, flexible, and easy-to-implement custom Flash video player class that can be used in any ActionScript 3.0 file. Some of the key highlights of the VideoMax class are:</p>
<ul>
<li><strong>Lightweight:</strong> Importing the VideoMax class and creating an instance adds only 12kb to overall file weight. Compare that to the built-in Adobe &#8216;flvPlayback&#8217; component, which adds 58kb to the overall file weight. Do the math. That&#8217;s nearly 500% heavier than this VideoMax class.</li>
<li><strong>Easy to Use:</strong> With just 3 lines of code, you can import the VideoMax class, create an instance of the player, and add it to your Flash file. And because of its dynamically-built nature, there are NO Library components needed. That&#8217;s right, NONE. All of the assets included in the VideoMax class are 100% built from scratch with nothing but ActionScript 3.0 code.</li>
<li><strong>Customizable:</strong> You can change a number of attributes to your VideoMax instances, so you can have a video player that is as unique as the video it plays. The customizable attributes include Width, Height, Auto Play, Auto Rewind, Auto Size, Buffer, Looping, Control Bar visibility, Tint, Play Button overlay, End Frame visibility, and onStart/onComplete listeners.</li>
<li><strong>Communicative:</strong> By using the onStart and onComplete listener attributes (and accompanying parameter attributes), you can have VideoMax dispatch events that call functions back in the parent file when the video starts and/or ends.</li>
<li><strong>Self-Sufficient:</strong> With its robust set of default attributes, VideoMax takes care of wrapping up all of the loose ends. Once you create your VideoMax instance, you can sit back and relax, knowing that everything is taken care of, including control bar resizing and positioning, buffering, automatic video resizing within the player, and more. Just import the class, create the instance, assign it attributes, and add it to your file. VideoMax will take care of the rest for you.</li>
</ul>
<h4>Where Can I Get VideoMax?</h4>
<p>VideoMax is available for download at the <a href="http://www.hesslerdesign.com/videomax">Official VideoMax Page</a> on HesslerDesign.com. There, you will find a free download of VideoMax, as well as examples and documentation on implementing VideoMax in your own Flash projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/mediaplayer-custom-flash-video-player-class-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top Ten Ways to Optimize Your Flash Website</title>
		<link>http://www.hesslerdesign.com/blog/flash/top-ten-ways-to-optimize-your-flash-website/</link>
		<comments>http://www.hesslerdesign.com/blog/flash/top-ten-ways-to-optimize-your-flash-website/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 17:45:12 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.hesslerdesign.com/blog/?p=324</guid>
		<description><![CDATA[Let&#8217;s face it.  When it comes to Flash websites, people either love them or hate them.  For those who hate them, I firmly believe it&#8217;s because of two main reasons: crappy SEO (search engine optimization), and long load times (a direct result of heavy file weights).  While the issue of SEO is its own beast, [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it.  When it comes to Flash websites, people either love them or hate them.  For those who hate them, I firmly believe it&#8217;s because of two main reasons: crappy SEO (search engine optimization), and long load times (a direct result of heavy file weights).  While the issue of SEO is its own beast, I won&#8217;t get into that now.  For now, I&#8217;m going to focus on 10 easy ways to optimize your Flash website to make it meaner, leaner, and more user-friendly.  Believe me, if you start using some of these ideas, your sites will transform in ways you never though imaginable.  And you&#8217;ll notice that you&#8217;ll get a much smoother and quicker site.  With that said, let&#8217;s get started.</p>
<h4>1. Use XML files to set content framework</h4>
<p>On nearly every Flash site I work on, I use at least some XML. The great thing about XML files is they are a great way to structure blocks of your site.  For instance, if you want a slideshow on your site, you could have an XML file that contains the title, url, and other image-specific information you want to include for each image. Then, just import the XML into Flash and store the XML data in arrays to organize the information to use later.  (More on arrays below.)</p>
<p>Another great thing about using XML in Flash is that if you want to stream an RSS feed into a Flash site, you can, because RSS feeds are set up as XML.  (For more info on RSS feeds, see the post on <a href="http://www.hesslerdesign.com/blog/flash-actionscript/streaming-rss-feeds-into-your-flash-application/" target="_self">Streaming RSS feeds into Your Flash Applications</a>.)</p>
<p>Additionally, XML is easy to change without having to republish your site.  Say you have that slideshow I mentioned above, but want to swap out an image.  With XML, you just point to the new url, update the title, and save. Your Flash site will automatically update with the new info, and you won&#8217;t have to republish every time. Trust me, you&#8217;ll thank yourself for using XML when you build your Flash site.</p>
<h4>2. Use arrays to organize assets used in your code</h4>
<p>For me, using arrays is quite possibly one of the smartest and most powerful things you can do to optimize your code.  Not necessarily from a file weight perspective, but because with arrays, you can reference an object stored in an array by name, number, id, etc. For instance, say you have 20 thumbnail images you want to make clickable to open a larger image. You could attach individual event listeners to each image.  Or, you could set up a couple of arrays &#8212; one for the instance names of each image, and one for the reference to the larger image to load when clicked &#8212; and run &#8220;for&#8221; loops to set the event listeners all at once. While you&#8217;re in the &#8220;for&#8221; loop, set an ID number for each image that you can then reference in your &#8220;click&#8221; function that will fire on mouse click, and call up that ID number slot in the large image array.  With only a few lines of code, you&#8217;ll have a powerful way to batch chunks of your code with minimal effort. (For more info on arrays, see my post on <a href="http://www.hesslerdesign.com/blog/flash-actionscript/utilizing-the-power-of-arrays-in-adobe-flash/" target="_self">Utilizing the Power of Arrays in Adobe Flash</a>.)</p>
<h4>3. Only import and embed absolutely necessary image files into your file.</h4>
<p>If you&#8217;ve been on the Web at all&#8230;and judging by you reading this, I&#8217;m guessing you have&#8230;you know doubt know that a lot of people don&#8217;t like Flash sites.  The main reason seems to be they take way too long to load.  To get around this, I highly suggest importing and embedding ONLY the images you absolutely need.  If you have a lot of image assets, I suggest loading them dynamically via code, and placing them in the appropriate places.  This not only makes the file size considerably smaller, but it also opens the door to be able to update an image, replace it, and have Flash automatically read in the updated file without the need to republish the entire site.  (Sorta sounds like one of the key perks of using XML, doesn&#8217;t it?)  And trust me, users will thank you for having a site that loads (or at least shows up with a short preloader) in 5 seconds, rather than a beefy site that doesn&#8217;t show up until the entire thing loads.</p>
<h4>4. Load assets in an orderly fashion, not all at once</h4>
<p>Along with #3 above, when you load assets into your Flash site dynamically, it&#8217;s best to set up a structure and order in which to load them. For instance, load all of the home/landing page assets first. Once those are loaded, proceed with the next set of assets that you think will be needed/viewed by your users.  Not using a certain set of images until later in the site?  Don&#8217;t load them up front. Wait until the rest of the assets before it have been loaded first. Think about it.  Would you rather try to have 20 images load all at once?  Or load them in the order of which they&#8217;ll be seen? Loading them one at a time will speed up the individual image load time because there is only one image needing attention while it is being loaded, not all 20?</p>
<h4>5. Cool it with the videos</h4>
<p>Okay, this sounds harsh, but hear me out. Video is great. It&#8217;s everywhere, and it&#8217;s getting more popular by the day.  (YouTube, anyone?)  But when you&#8217;re making a Flash site, video can also be a beast to work with, specifically video that needs to stream without a playback bar.  The worst thing about video is file size. I&#8217;ll admit, video has come a long way in optimizing file weights and all, but at the end of the day, even a small video is still going to be around 1-2MB.  When you are using video, make sure you utilize the &#8220;loading assets in an orderly fashion&#8221; advice from above.  If you try to start streaming a video when 20 images are loading while it&#8217;s trying to play, you&#8217;ll no doubt get choppy playback.</p>
<h4>6. Use TweenMax or TweenLite for code-based tweening and animating</h4>
<p>I&#8217;m a big fan of keeping my Flash sites on one frame of the timeline, and doing as much as I possibly can with code, rather than with the timeline.  The reason for this is simply less time making changes later on down the road.  Want to make every tween of an image fading out half as long across the entire site?  Pretty laborious if you&#8217;re using the timeline.  But if you&#8217;re using code, it&#8217;s a matter of updating a couple of numbers.</p>
<p>This is where <a href="http://blog.greensock.com/tweenmax/" target="_blank">TweenMax</a> and <a href="http://blog.greensock.com/tweenlite/" target="_blank">TweenLite</a> come in.  In a nutshell, they&#8217;re the best tweening engine out there.  Using it, you can call one function that can alter many facets of an object at once (x and y position, alpha, tint, etc.).  You can also attach event listeners like onComplete, onStart, etc., that call functions to run at specific times during the tween.  In short, these tweening engines will make you wonder why you ever used timeline-based animations.  And best of all, they&#8217;re extremely light in file weight, unlike a lot of timeline-based animations.  And it&#8217;s a one-time file weight addition, not a per-tween sort of thing.</p>
<h4>7. Simulate downloading on slower connections</h4>
<p>Not everyone has a cable-speed connection. Believe it or not, there are still a lot of people out there using DSL or slower connections.  And as unfortunate as it may be, those are the people you need to build the site for.  Don&#8217;t ever assume that your audience is going to have the latest and greatest computers.</p>
<p>To simulate downloads in Flash, export your movie and select &#8220;View &gt; Simulate Download&#8221;.  To set different connection speed settings, select &#8220;View &gt; Download Settings&#8221;, and select your desired speed (or create your own custom speed).  Flash can be deceiving. When you test out a movie, it always runs lightning fast. But by testing it using the &#8220;Simulate Download&#8221; method, you&#8217;ll get a much better idea of how your site will behave on the Web.</p>
<h4>8. Build buttons and other UI components as vector artwork in Flash</h4>
<p>One of my biggest pet peeves is using raster images for buttons that could easily be made as vector art in Flash.  Not only does this make having to update the button a multi-step process, but it also beefs up the size of the file.  It may not be much, but if you get a dozen different image buttons, you could easily have just added 100+ kb to your file weight.  Might not seem by much, but as people&#8217;s attention spans are getting shorter and shorter, that added 2 seconds of load time you just added might be costly, and you may see an increase in the number of dropped users.</p>
<p>My motto is this: &#8220;<em>If it can be made in Flash, make it in Flash&#8221;</em>.  Vector art is not only easily editable, but also a huge file weight saver.  Plus, you don&#8217;t get any degradation of quality that you&#8217;d get if you used images.  All of your lines, colors, gradients, etc. are crystal clear.  Pair that with the almost non-existent file weight they carry, and what&#8217;s not to love?</p>
<h4>9. Write custom Classes for reusable code</h4>
<p>If you write Actionscript code, you use Classes.  You might not know it, but you do.  Every time you use a property of a MovieClip instance (i.e. myClip_mc.y to get the &#8220;y&#8221; position), you&#8217;re calling the MovieClip class.  Same with Sprites, Buttons, UI Components, etc.  Classes are a staple in object-oriented programming, and allow you to read or set properties, call functions (methods), and respond to events.  It&#8217;s a great way to reuse the same code over and over again, by simply importing the classes into your site file.</p>
<p>One of my personal favorite classes that I have written is for an Email Validator, which contains the logic to check whether a string is a valid email address or not.  You can check it out in my previous post on <a href="http://www.hesslerdesign.com/blog/flash-actionscript/building-a-better-email-validator-in-flash/" target="_self">Building a Better Email Validator in Flash</a>.  Each time I need to use this, I simply import it into my file (which is 1 line of code), make an instance of the validator (1 line of code), then call the validate function and pass in the string to validate (1 line of code).  In all, for me to validate an email address, it takes 3 lines of code.  Much better than rewriting all of the validation logic in a dozen different files, eh?</p>
<h4>10. Use FlashVars to set important global variables</h4>
<p>Every so often, you&#8217;ll run into an issue where you&#8217;ll want to change a variable from outside of your Flash file. An easy way to do this is to use the FlashVars parameter when embedding your Flash file in HTML.  I find that I mostly use FlashVars for variables that will change from a &#8220;staging&#8221; site to the final &#8220;production&#8221; site.  The most often used variable that I personally encounter is the account name for Omniture tracking. The bulk of sites I develop have different staging and production Omniture account names, so the metrics don&#8217;t get skewed while testing.  But if I embed that account name into the Flash file, I suddenly need 2 different versions of the Flash file &#8212; one for staging, one for production.  But if I have a FlashVar set up for this account name, I can just change the variable in the HTML code, and have Flash read it in.  Trust me, it&#8217;s a handy way to avoid having multiple versions of the same file for different environments.</p>
<h4>In Conclusion&#8230;</h4>
<p>So there you have it.  10 easy ways to optimize your Flash sites.  There are many more ways to optimize Flash sites, and I&#8217;m sure I&#8217;ll get into them in later posts.  But these are some of the main culprits.  And trust me, individual posts could be written about each one of these (and some already have).  If you want to see posts that dive deeper into any of these, just let me know and I&#8217;ll write it up.  Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hesslerdesign.com/blog/flash/top-ten-ways-to-optimize-your-flash-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

