<?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>Padizine Blog&#187; Flash</title>
	<atom:link href="http://www.padizine.com/blog/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.padizine.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 14 Jul 2011 14:41:46 +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>SWFAddress Tutorial For ActionScript 2.0</title>
		<link>http://www.padizine.com/blog/swfaddress-tutorial-for-actionscript-2-0/</link>
		<comments>http://www.padizine.com/blog/swfaddress-tutorial-for-actionscript-2-0/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 16:56:35 +0000</pubDate>
		<dc:creator>Alex Petrisor</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.padizine.com/blog/?p=103</guid>
		<description><![CDATA[Recently I've been working on my portfolio at padizine.com which is a full Flash AS2 website. It is still WIP, but I knew that I had to do something from a SEO point of view. Flash SEO has always been a big controversy, even after the changes that google brought to flash indexing, but there are some tricks that work well. The first thing that I did was to get deep linking working. What's deep linking you ask? Well keep on reading!]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been working on my portfolio at <a title="Padizine Online Portfolio" href="http://www.padizine.com" target="_blank">padizine.com</a> which is a full Flash AS2 website. It is still WIP, but I knew that I had to do something from a SEO point of view. Flash SEO has always been a big controversy, even after the changes that google brought to <a title="Improved Flash Indexing" rel="external nofollow" href="http://googlewebmastercentral.blogspot.com/2008/06/improved-flash-indexing.html" target="_blank">flash indexing</a>, but there are some tricks that work well. The first thing that I did was to get deep linking working. What&#8217;s <a title="Deep Linking" rel="external nofollow" href="http://en.wikipedia.org/wiki/Deep_linking" target="_blank">deep linking</a> you ask? Well keep on reading!</p>
<h2>What deep linking is and how it can help you.</h2>
<p>Well normally for any flash website you would have a Flash SWF file embedded in a HTML page. Whenever a visitor clicks on a link in the menu and is taken to a different page in your site, the actual HTML page and thus the URL doesn&#8217;t change. The change is made within the Flash SWF and the user is taken to a different zone within the timeline, or a different page is shown through ActionScript. That means that however many pages your flash site will have, you will only have one URL address. This causes quite a few disadvantages:</p>
<ul>
<li>If someone presses the browser back button while deep in your page hierarchy, he will be taken to the page visited prior to your homepage, as there is no history entry for your individual pages.</li>
<li>That also means that visitors can only bookmark your homepage.</li>
<li>And that also means that you can only have one HTML &lt;title&gt; that will stay the same regardless of what page the visitor is on.</li>
</ul>
<p>Deep linking solves all these problems beautifully. All the pages inside your Flash file will generate different URLs, and have different titles. Because of that they will also create history entries in the browser, and the user will be able to use the back and forward buttons on your site. Finally, you can supply visitors with links that take them directly to an area inside your site. Flash SEO has been waiting for this for years. Too good to be true? It&#8217;s actually not, but you have to admit that it&#8217;s damn sweet.</p>
<h2><span class="dropcap1">1</span>Preparing your HTML by using swfaddress.js</h2>
<p>So how is this possible? Well by using a great tool called <strong>SWFAddress</strong>, thanks to the awesome folks at <a title="Asual.com" rel="external nofollow" href="http://www.asual.com/" target="_blank">Asual.com</a>. To get started, you will need to download SWFAddress <a title="SWFAddress" rel="external nofollow" href="http://www.asual.com/swfaddress/" target="_blank">here</a>.</p>
<p>After you extract the files, you will see a folder called <strong>dist</strong>. This is the distribution folder and it contains all the files that we will need. First, browse to <strong>dist\js</strong> and copy <strong>swfaddress.js</strong> to the root folder of your website, where index.html is. I assume that you are using SWFObject to load the flash into the HTML.</p>
<p>In your <strong>&lt;head&gt;</strong>, right after<br />
<div class="fancy_box">&lt;script type=&#8221;text/javascript&#8221; src=&#8221;swfobject.js&#8221; charset=&#8221;utf-8&#8243;&gt;&lt;/script&gt;</div>add<br />
<div class="fancy_box">&lt;script type=&#8221;text/javascript&#8221; src=&#8221;swfaddress.js&#8221; charset=&#8221;utf-8&#8243;&gt;&lt;/script&gt;</div></p>
<p>This makes sure that your page will load the swfaddress.js and use it accordingly. Make sure that it&#8217;s <strong>after</strong> the SWFObject declaration.</p>
<h2><span class="dropcap1">2</span>Adding SWFAddress to your Flash file</h2>
<div class="fancy_header"><span>1. Importing the SWFAddress library</span></div>
<p>This is where it gets interesting. First we will need to include the SWFAddress library in our FLA. I&#8217;ve created a folder on my hard drive that holds several tools and libraries. This keeps me organised and keeps my libraries safe from random <em>format c:</em> moments <img src='http://www.padizine.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So let&#8217;s say that the path for our external ActionScript code is <strong>E:\Tools\AS</strong>. You will need to go to the <strong>dist\as\2</strong> folder in your SWFAddress folder, and copy the <strong>com</strong> folder over to <strong>E:\Tools\AS</strong>. These are the libraries for ActionScript 2.</p>
<p>Next, in your FLA file, go to <strong>Publish Settings &gt; Flash &gt;</strong> And next to ActionScript 2.0 click on <strong>Settings</strong>. Here you will need to add the path to your <strong>E:\Tools\AS</strong> folder.</p>
<p>For the SWFAddress functions to work when you compile your FLA, you need to include the library in your ActionScript like this:<br />
<div class="fancy_box">import com.asual.swfaddress.SWFAddress;</div>You need to put this on the first line of <strong>every frame of ActionScript that uses SWFAddress functions</strong>.</p>
<p>The next bit is and will be depending on how your site is actually built. There are a few methods that you need to call, depending on what is happening inside your movie.</p>
<div class="fancy_header"><span>2. Using the SWFAddress library to enable deep linking<br/>on your flash website</span></div>
<p>Fist of all, there is <strong>SWFAddress.setValue()</strong>. This one sets the current URL to the value thrown at it, prefixed by <strong>#/</strong>. For example, if my flash page is at <em>http://yoursite.com</em>, and you run <strong>SWFAddress.setValue(&#8220;awesome&#8221;)</strong>, the URL will turn into <em>http://yoursite.com/#/awesome</em>. It&#8217;s as simple as that! However, that only changes the URL you see, if someone actually typed in that URL in their browser it wouldn&#8217;t work. We will get to that in a moment, but first let&#8217;s make sure this setValue() thing sinks in <img src='http://www.padizine.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So where would you use this? Well let&#8217;s say that you have a menu button called About, that takes you to your About page. You will need to add the setValue() function here then:</p>
<div class="fancy_box">About.onRelease = function()
<div>{</div>
<div style="padding-left: 30px;">SWFAddress.setValue(&#8220;about&#8221;);</div>
<div style="padding-left: 30px;">//Navigation code</div>
<div>}</div>
</div>
<p>So when someone presses About, they get taken to the About page, and the URL changes accordingly. This was a pretty basic example, but wherever you place setValue(), you will use the same logic. For example, on my website I load my menu dynamically from an XML file. I then add a click function to all the buttons, that would look like this:</p>
<div class="fancy_box">_global.clickFunction = function (object)
<div>{</div>
<div style="padding-left: 30px;">SWFAddress.setValue(object.name.text.toLowerCase());</div>
<div style="padding-left: 30px;">//Navigation code</div>
<div>}</div>
</div>
<p>Secondly, there is the <strong>SWFAddress.setTitle()</strong> function. This works in the same way as setValue() but instead of changing the URL it changes the title displayed in your browser window. This is pretty straightforward, so we will go on to the last and most important function which is&#8230;</p>
<p><strong>SWFAddress.onChange() </strong>is where all the magic happens. This function automatically gets triggered whenever the URL changes, either from your application, or from the browser itself. So this is basically where you make your website navigate to a certain page when it &#8220;sees&#8221; that the URL has changed. In my FLA, I have a lot of stuff happening on frame 1 of the stage (loading XML, resizing window etc.) so that is where I put this function:</p>
<div class="fancy_box">SWFAddress.onChange = function()
<div>{</div>
<div style="padding-left: 30px;">var addr = SWFAddress.getValue(); //This gets the current URL, but only what was appended to <em>http://yoursite.com/#</em></div>
<div style="padding-left: 30px;">switch (addr)</div>
<div style="padding-left: 30px;">{</div>
<div style="padding-left: 60px;">case &#8220;/&#8221;:</div>
<div style="padding-left: 90px;">SWFAddress.setTitle(&#8216;My Homepage&#8217;);</div>
<div style="padding-left: 90px;">//Code for navigation to <em>homepage</em> goes here</div>
<div style="padding-left: 90px;">break;</div>
<div style="padding-left: 60px;">case &#8220;/awesome&#8221;:</div>
<div style="padding-left: 90px;">SWFAddress.setTitle(&#8216;My Website &#8211; Awesome&#8217;);</div>
<div style="padding-left: 90px;">//Code for navigation to <em>awesome page</em> code goes here</div>
<div style="padding-left: 90px;">break;</div>
<div style="padding-left: 60px;">//And so on</div>
<div style="padding-left: 30px;">}</div>
<div>}</div>
</div>
<p>And that&#8217;s about it! Remember that this function gets called when the browser changes the URL, i.e. when someone is pressing the back button, but <strong>also</strong> when your application changes the URL. Why is this so important? Because when you place the setValue() code like explained above, you won&#8217;t need any more Navigation code whatsoever! When setValue() changes the URL for you, onChange() is called and the navigation is done anyway. So the <strong>onRelease</strong> method would become something like this:</p>
<div class="fancy_box">About.onRelease = function()
<div>{</div>
<div style="padding-left: 30px;">SWFAddress.setValue(&#8220;about&#8221;);</div>
<div>}</div>
</div>
<div class="fancy_header"><span>3. XML Troubleshooting</span></div>
<p>When you have a site that loads all the stuff via an XML file and external SWFs that might load other XML files and other external SWFs, it can get a bit tricky. The main problem that I faced was that SWFAddress.onChange() would get called before the site managed to load the XML, thus the menu and everything else. This happened when someone typed in an URL that was already deep in the hierarchy. So whatever URL they typed in, they still ended up on the homepage.</p>
<p>So to fix this, I simply went to the the XML load function, and when the XML gets loaded completely I simply call <strong>SWFAddress.onChange()</strong>. This way, if it was called before the site got loaded and didn&#8217;t do anything, after it loads it is called again, checks the URL, and takes the user to the correct page.</p>
<h2><span class="dropcap1">3</span>Conclusion and Flash SEO</h2>
<p>Search engines really care about URLs and what they look like. You can read more about this in my previous post, <a title="Drupal SEO for URLs" href="http://www.padizine.com/blog/drupal-seo-for-urls/" target="_blank">Drupal SEO for URLs</a>. More and more Flash sites are picking up on this, and that&#8217;s great. Fact is, for the best possible implementation of SWFAddress, you need to think about it before developing your site, and write your code in such a way that it helps SWFAddress instead of hindering it. If you&#8217;d like to know more, there&#8217;s a host of resources available at <a title="SWFAddress Resources" rel="external nofollow" href="http://www.asual.com/swfaddress/resources/" target="_blank">Asual.com</a>.</p>
<p>SEO for Flash has always been a tough battle, but with such a great ally on our side, I can&#8217;t stop thinking that we will <em>get there</em> at some point. Have something to <a title="Comment on this" href="#respond">say</a>? Go ahead then!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.padizine.com/blog/swfaddress-tutorial-for-actionscript-2-0/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>

