<?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>Enhancing Human Experiences &#187; ActionScript</title>
	<atom:link href="http://blog.humancentric.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.humancentric.com</link>
	<description>We believe that great experiences come from understanding people.</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:52:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Flash: Browser-Accessible and SEO-Friendly</title>
		<link>http://blog.humancentric.com/flash-browser-accessible-and-seo-friendly/</link>
		<comments>http://blog.humancentric.com/flash-browser-accessible-and-seo-friendly/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 19:20:11 +0000</pubDate>
		<dc:creator>Mark Dezelon</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.humancentric.com/?p=563</guid>
		<description><![CDATA[When we built the HumanCentric website, we wanted to take advantage of Flash&#8217;s animation and drawing capabilities. However we didn&#8217;t want to alienate search engines (&#8220;Search Engine Optimization&#8221;, or &#8220;SEO&#8221;) and users who do not have Flash or JavaScript enabled. We took advantage of SWFObject, SWFAddress and PHP, and we devised a method for showing [...]]]></description>
			<content:encoded><![CDATA[<p>When we built the <a title="http://www.humancentric.com/" href="http://www.humancentric.com/" target="_blank">HumanCentric website</a>, we wanted to take advantage of <a title="http://www.adobe.com/products/flashplayer/" href="http://www.adobe.com/products/flashplayer/" target="_blank">Flash&#8217;s</a> animation and drawing capabilities.  However we didn&#8217;t want to alienate search engines (&#8220;Search Engine Optimization&#8221;, or &#8220;SEO&#8221;) and users who do not have Flash or JavaScript enabled.  We took advantage of SWFObject, SWFAddress and PHP, and we devised a method for showing the same content regardless of browser capability.<br />
<span id="more-563"></span></p>
<p>On our website, we use <a title="http://code.google.com/p/swfobject/" href="http://code.google.com/p/swfobject/" target="_blank">SWFObject</a> which provides a cross-platform HTML-compliant method for embedding a Flash SWF to a webpage.  A web developer creates a DIV element in an HTML document with content that is displayed if the user doesn&#8217;t have Flash or JavaScript enabled in the browser.  If the user&#8217;s browser is compliant, then SWFObject replaces that DIV with the Flash SWF, and the user never sees the original content.</p>
<p>We also use <a title="http://www.asual.com/swfaddress/" href="http://www.asual.com/swfaddress/" target="_blank">SWFAddress</a> to enable browser-recognized pages in our Flash website.  Including SWFAddress adds a hash (&#8220;#&#8221;) into our url; everything before the hash points to our website root, and everything after the hash is sent to our SWF so it can display the correct page.  Clicking a browser&#8217;s back or forward button displays the correct internal page even though the same SWF is displayed each time.</p>
<p><a title="http://www.google.com/" href="http://www.google.com/" target="_blank">Google</a> has made great strides in <a title="http://googlewebmastercentral.blogspot.com/2008/06/improved-flash-indexing.html" href="http://googlewebmastercentral.blogspot.com/2008/06/improved-flash-indexing.html" target="_blank">indexing Flash applications</a>, but they still treat all internal pages within a single SWF as one page.  For example, the following urls are unique:</p>
<ul>
<li><a title="http://www.humancentric.com/" href="http://www.humancentric.com/" target="_blank">http://www.humancentric.com/</a></li>
<li><a title="http://www.humancentric.com/#/portfolio" href="http://www.humancentric.com/#/portfolio" target="_blank">http://www.humancentric.com/#/portfolio</a></li>
<li><a title="http://www.humancentric.com/#/labs" href="http://www.humancentric.com/#/labs" target="_blank">http://www.humancentric.com/#/labs</a></li>
</ul>
<p>However they are all treated as if http://www.humancentric.com/ was a giant page with varying content.  We want Google to recognize our different pages.  And because we strive to be Good Web Developers™, we also want non-Flash browsers and search engines to view our content.</p>
<p>For non-Flash clients to view our site, we&#8217;ve created a second HTML-only version.  All of our content lives in XML files that the Flash version reads, parses and displays for Flash-compatible clients.  Our HTML version reads these same XML files and, using <a title="http://www.php.net/" href="http://www.php.net/" target="_blank">PHP</a>, dynamically produces XHTML-compatible code for non-Flash clients.  Thus our content lives in one place, but now it&#8217;s accessible to both types of users.</p>
<p>We&#8217;ve configured our site so if a user goes to <a title="http://www.humancentric.com/portfolio" href="http://www.humancentric.com/portfolio" target="_blank">http://www.humancentric.com/portfolio</a>, the HTML version of the Portfolio page is generated.  If a user has JavaScript and Flash, then the browser is automatically redirected (via JavaScript) to <a title="http://www.humancentric.com/#/portfolio" href="http://www.humancentric.com/#/portfolio" target="_blank">http://www.humancentric.com/#/portfolio</a>.  When the user go to the new url, our homepage is generated and displayed in a DIV element, but SWFObject immediately replaces it with the SWF, and SWFAddress sends it the &#8220;/portfolio&#8221; portion.</p>
<p>Our website is browser-accessible because a user can use the browser&#8217;s back and forward buttons, and each of our pages appears in the browser history. It is SEO-friendly because each internal page has its own unique link with non-Flash HTML content. And it is accessible to non-Flash users for the same reasons.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.humancentric.com/flash-browser-accessible-and-seo-friendly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash: Using ColorMatrixFilter to Reduce Load Time</title>
		<link>http://blog.humancentric.com/flash-using-colormatrixfilter-to-reduce-load-time/</link>
		<comments>http://blog.humancentric.com/flash-using-colormatrixfilter-to-reduce-load-time/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 19:12:40 +0000</pubDate>
		<dc:creator>Mark Dezelon</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Interaction Design]]></category>
		<category><![CDATA[Web & Software]]></category>

		<guid isPermaLink="false">http://blog.humancentric.com/?p=134</guid>
		<description><![CDATA[When dynamically loading different color variations of the same graphic, Flash developers can use flash.filters.ColorMatrixFilter to lessen website loading times. Below is an example of how we use ColorMatrixFilter in our own website. Among other specialties, I develop Flash prototypes and websites. In fact, I&#8217;m part of the team that built the HumanCentric website. And [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.humancentric.com/wp-content/uploads/2009/06/logos.jpg" alt="HumanCentric Clients" title="HumanCentric Clients" width="535" height="213" /></p>
<p>When dynamically loading different color variations of the same graphic, Flash developers can use flash.filters.ColorMatrixFilter to lessen website loading times. Below is an example of how we use ColorMatrixFilter in our own website.</p>
<p>Among other specialties, I develop Flash prototypes and websites.  In fact, I&#8217;m part of the team that built the <a title="HumanCentric website" href="http://www.humancentric.com/" target="_blank">HumanCentric website</a>.  And one aspect that&#8217;s important to me is the time it takes a user to load individual parts of a website.  For example, if a user goes directly to one of our pages, their browser will retrieve a pre-loading Flash application, a main Flash application, a site xml description, a page-specific xml description, and any images specific to that page.</p>
<p><span id="more-134"></span></p>
<p>Our <a title="HumanCentric | About Us | Clients" href="http://www.humancentric.com/#/about/clients/" target="_blank">About Us | Clients page</a> has a grid of grayscale client logos.  When a user hovers her mouse over a logo, it fades to a color image.  At 30 logos with two variants for each logo (grayscale and color), the application must load 60 images.  That&#8217;s a lot of graphics, even if they are small, especially if someone has a slow Internet connection.</p>
<p>I was able to reduce our count of images by 50% using <a title="ActionScript 3.0 | ColorMatrixFilter" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/filters/ColorMatrixFilter.html" target="_blank">ColorMatrixFilter</a>, which alters the colors of an entire image on-the-fly.  For each logo, I can load up a single color image and later apply a ColorMatrixFilter to display a grayscale image.  If I want to apply a different effect, such as lowering saturation or increasing brightness or emphasizing the redness of an image, ColorMatrixFilter can dynamically provide these effects. This has an added benefit that when a color image is loaded, the grayscale variant is created immediately, preventing any cases where only one image is loaded when the user hovers her mouse over a logo.</p>
<p>Below is some sample ActionScript 3.0 code with the package declaration and import statements removed.  Within ClientSprite, I have two DisplayObjects:  graySprite which loads the bitmap and applies a ColorMatrixFilter, and colorSprite which borrows the bitmapData loaded from graySprite.</p>
<p>[code lang="actionscript"]</p>
<pre>public class ClientSprite extends Sprite
{
    // private constants

    private static const GRAY_FILTER_PARAMS:Array = [
        0.3086, 0.6094, 0.082, 0, 0,
        0.3086, 0.6094, 0.082, 0, 0,
        0.3086, 0.6094, 0.082, 0, 0,
        0, 0, 0, 1, 0];
    private static const GRAY_FILTER_MATRIX:ColorMatrixFilter
        = new ColorMatrixFilter(GRAY_FILTER_PARAMS);
    private static const GRAY_ALPHA:Number = .4;

    private static const TWEEN_DURATION:Number = .2;

    // private variables

    private var graySprite:Loader;
    private var colorSprite:Sprite;
    private var tween:Tween;

    // constructor

    public function ClientSprite(bmpUrl:String)
    {
        // create gray image
        this.graySprite = new Loader();
        this.graySprite.alpha = GRAY_ALPHA;
        this.graySprite.filters = [GRAY_FILTER_MATRIX];
        this.graySprite.contentLoaderInfo.addEventListener(
            Event.COMPLETE, this.onColorImageLoaded);
        this.graySprite.load(new URLRequest(bmpUrl));
        this.addChild(this.graySprite);

        // create color image
        this.colorSprite = new Sprite();
        this.colorSprite.alpha = 0;
        this.addChild(this.colorSprite);

        // add callbacks
        this.addEventListener(MouseEvent.MOUSE_OVER,
            this.onMouseOver);
        this.addEventListener(MouseEvent.MOUSE_OUT,
            this.onMouseOut);
    }

    // private callbacks

    private function onColorImageLoaded(e:Event):void
    {
        var grayBitmap:Bitmap =
            (this.graySprite.content as Bitmap);
        var colorBitmap:Bitmap = new Bitmap(
            grayBitmap.bitmapData, PixelSnapping.ALWAYS,
            true);
        this.colorSprite.addChild(colorBitmap);
    }

    private function onMouseOver(e:MouseEvent):void
    {
        this.tweenColorAlphaTo(1);
    }

    private function onMouseOut(e:MouseEvent):void
    {
        this.tweenColorAlphaTo(0);
    }

    // private methods

    private function tweenColorAlphaTo(newAlpha:Number):
        void
    {
        if(this.tween)
        {
            this.tween.stop();
        }
        this.tween = new Tween(this.colorSprite, "alpha",
            Regular.easeOut, this.colorSprite.alpha, newAlpha,
            TWEEN_DURATION, true);
    }
}</pre>
<p>[/code]</p>
<p>I gleaned most of my knowledge of the ColorMatrixFilter class from Adobe&#8217;s Developer Connection article <a title="Using Matrices for Transformations, Color Adjustments, and Convolution Effects in Flash" href="http://www.adobe.com/devnet/flash/articles/matrix_transformations_04.html" target="_blank">Using Matrices for Transformations, Color Adjustments, and Convolution Effects in Flash</a>.  They even have a live app where you can supply your desired Brightness, Contrast, Saturation and Hue settings, and it will calculate the equivalent matrix data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.humancentric.com/flash-using-colormatrixfilter-to-reduce-load-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
