<?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>noponies &#187; tutorial</title>
	<atom:link href="http://www.blog.noponies.com/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.noponies.com</link>
	<description>I want a pony for xmas! Flash, ActionScript, Drawing, Code, Illustration from New Zealand.</description>
	<lastBuildDate>Mon, 12 Jul 2010 10:37:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Asdoc under OSX</title>
		<link>http://www.blog.noponies.com/2009/07/using-asdoc-under-osx/</link>
		<comments>http://www.blog.noponies.com/2009/07/using-asdoc-under-osx/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 14:38:33 +0000</pubDate>
		<dc:creator>Dale</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[asdoc]]></category>
		<category><![CDATA[flex 4]]></category>
		<category><![CDATA[using asdoc under osx]]></category>

		<guid isPermaLink="false">http://www.blog.noponies.com/?p=297</guid>
		<description><![CDATA[At work I&#8217;m without my install of Flex, and its various niceities like ant builds for creating ASDoc documentation for my various classes and work projects.
In the past I&#8217;ve messed around with the commandline controls for creating ASDoc documentation, but without a great deal of success. 
However, at work today, I decided to get it [...]]]></description>
			<content:encoded><![CDATA[<p>At work I&#8217;m without my install of Flex, and its various niceities like ant builds for creating ASDoc documentation for my various classes and work projects.</p>
<p>In the past I&#8217;ve messed around with the commandline controls for creating ASDoc documentation, but without a great deal of success. </p>
<p>However, at work today, I decided to get it working and create some documentation. There are a range of options for creating asdoc documents on the mac, I&#8217;ll list them below.</p>
<p>1 / Command line. Downloading the <a href="http://labs.adobe.com/technologies/flex4sdk/">Flex SDK</a> and kicking it command line style.</p>
<p>2 / Getting a copy of <a href="http://www.adobe.com/products/flex/">Flex</a>, and using <a href="http://blog.bittube.com/2006/08/15/ant-buildxml-for-asdocs-generation/">Ant</a> to build your docs.</p>
<p>3 / Using either the SDK, or Flex but a front end tool like <a href="http://code.google.com/p/dita/">Dita</a> to generate the shell scripts for you, that you then run in terminal to create your docs.</p>
<p>I&#8217;ve used Dita and Flex with an Ant build on my home mac. At work, I use the command line approach.</p>
<p>Heres how I got it to work, using the new Flex 4 SDK beta and the OSX terminal.</p>
<p>a / Make sure you have downloaded the latest <a href="http://labs.adobe.com/technologies/flex4sdk/">Flex SDK</a>. Unzip it and place it somewhere on your hard drive. Mine lives in the &#8220;Developer&#8221; folder of my OSX boot disk.<br />
b / Open up a text editor. I always find it easier to work out my terminal commands in a text editor, and simply paste in what I want into termainl when I&#8217;m ready.<br />
c / Find the path to your bin folder within your Flex SDK folder. The simplest way, is to simply drag n drop the bin folder into an empty terminal window, which will then give you the path to the folder. Or simply, type it out manually. You now need to tell terminal to work from this &#8216;bin&#8217; directory, via the &#8216;cd&#8217; command. The syntax for that is below;</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">cd path-to-you-flex-sdk-bin-folder</pre></div></div>

<p>d / Now you can simply run the various <a href="http://livedocs.adobe.com/flex/gumbo/html/WSd0ded3821e0d52fe1e63e3d11c2f44bc36-7ffa.html">asDoc commands</a> to generate your documentation. The various commands I&#8217;ve used to create the documentation for my NpFSObjectresize class are listed below. Make sure the asdoc commands are all on one long line. For some reason, I had to have the footer and window title before the -doc-sources parameter.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">cd /Developer/SDKs/flex_sdk_4.0.0.7219/bin/
./asdoc -main-title=&quot;NpFSOBjectResize Class&quot; -window-title=&quot;Noponies NpFSOBjectResize Class&quot; -footer=&quot;Copyright <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">'http://www.blog.noponies.com'</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">'Visit Class Author'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Noponies<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 2009&quot; -doc-sources=/Users/dsattler/Desktop/sample/noponies -output=/Users/dsattler/Desktop/sample/docs</pre></div></div>

<p>As you can see from the example above, I have a folder called &#8217;sample&#8217; on my desktop with my actionscript residing in a folder called &#8216;noponies&#8217;. I&#8217;m simply outputting my docs to a folder called &#8216;docs&#8217; which resides within that &#8217;sample&#8217; folder.</p>
<p>When you are ready, simply paste in your ASDoc commands into terminal, and you should see the asdoc tool run through its various steps. One thing I&#8217;ve noticed is that the Flex 4 ASDoc tool is much more strict about correctly closing html tags etc within your documentation. A missing closing <code>/p</code> caught me out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.noponies.com/2009/07/using-asdoc-under-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Approaches for Multi Language ActionScript 3 Websites</title>
		<link>http://www.blog.noponies.com/2009/01/approaches-for-multi-language-actionscript-3-websites/</link>
		<comments>http://www.blog.noponies.com/2009/01/approaches-for-multi-language-actionscript-3-websites/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 03:06:15 +0000</pubDate>
		<dc:creator>Dale</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flash CS3]]></category>
		<category><![CDATA[Flash language files]]></category>
		<category><![CDATA[XML language files]]></category>

		<guid isPermaLink="false">http://www.blog.noponies.com/?p=125</guid>
		<description><![CDATA[How best to approach setting up a Flash based website to handle?Ç¬†multiple?Ç¬†languages is often a topic of discussion at the various Flash forums I frequent.
Adobe have a few pointers for creating multi language Flash projects, using the Strings Panel. This looks OK, but I&#8217;ve never actually used it, so cant really comment beyond reading over [...]]]></description>
			<content:encoded><![CDATA[<p>How best to approach setting up a Flash based website to handle?Ç¬†multiple?Ç¬†languages is often a topic of discussion at the various Flash forums I frequent.</p>
<p>Adobe have a few pointers for creating multi language Flash projects, using the <a title="Adobe Strings Panel Documentation" href="http://help.adobe.com/en_US/Flash/10.0_UsingFlash/WS754A19FC-48CE-49ee-8EF2-B9C927F64BEB.html" target="_blank">Strings Panel</a>. This looks OK, but I&#8217;ve never actually used it, so cant really comment beyond reading over the documentation.</p>
<p>My approach to mulitlanguage files consists of creating a seperate XML file for each language I want to use in the application, and then loading that file at load time where a user can select it before the site loads and allowing for the user to change the language file at runtime, after the site has loaded and all content is displayed. If a user selects a language file then that selection is stored as a SharedObject, so that with subsequent site loads, the language file is automatically selected and loaded.</p>
<p>Setting up a Flash project for multiple language selection is fairly painless. I&#8217;ll run through a general approach to setting up your projects, and then a couple of ActionScript implementations that explore different means of achieving the same result; namely load and runtime selection of language files. One note, is that these example files are pure ActionScript projects, all content is dynamically created. However, if you have static content, the general principles will still apply.</p>
<p>The first thing you will want to set up is your XML language files. I&#8217;ve created two, an English and a French version. (The French version is just some google translated English text, so excuse the probably massive translation errors <img src='http://www.blog.noponies.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). The english.xml file is below.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--  English XML File - 2008 --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;website</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;english&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lang</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;changelang&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Change Language&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;noponies</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;blog&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;View Blog Entry&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://www.blog.noponies.com/feed&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;noponies</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;illustrations&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;View Illustrations&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://www.noponies.com/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;noponies</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;about&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;About&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://www.blog.noponies.com/about&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ui<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- DUMMY --&gt;</span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;people<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;person</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;people/director&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Dale Sattler&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[&lt;p&gt;&lt;strong&gt;About&lt;/strong&gt;</span>
&nbsp;
<span style="color: #339933;">I?¢‚Ç¨‚Ñ¢m a New Zealand based Designer and Illustrator. Apart from what you see here I like to surf, draw and enjoy the outdoors.</span>
&nbsp;
<span style="color: #339933;">This site is little blog to place the Flash and other technical stuff that does not fit into my main http://www.noponies.com site, which is more focused on my illustration and design.</span>
&nbsp;
<span style="color: #339933;">Drop me a line if you find the files useful and maybe even send me a link to the site in which it was used. Feel free to make a donation to my paypal account if you want to reward me for the effort I put into making this resource. Its not a requirement, but is nice. &lt;/p&gt;]]&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>	
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/person<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/people<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/website<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>As you can see, the XML is wrapped in an <code>website</code> tag with an attribute for the language, called &#8220;lang&#8221;. We then have a <code>ui</code> and a <code>people</code> tag, with various children. The <code>ui</code> tag, will provide our sites interface with its text labels, and the <code>people</code> tag will simply provide us with some dummy text content. </p>
<p>The most important element to pick up from the XML file, is the use of the <code>id</code> attribute for each XML fragment that corresponds to some actual content in our Flash website. This <code>id</code> attribute <strong>must</strong> be unique for each element and is used by Flash a key when we search through each XML file, matching the <code>id</code> attribute against each of our Flash sites elements own id tags. This key based approach is also the means by which I create Flash sites that use SWFAddress. Each XML element also has either a <code>title</code> or a <code>text</code> tag which corresponds to the Flash elements actual content. If you contrast the english.xml against the french.xml, you will see that the <code>id</code> attributes are unchanged, <strong>it is only</strong> the <code>title</code> or <code>text</code> elements that change.</p>
<p>So, that is the XML part of the project explained. Now, onto the Flash implementations. As I mentioned earlier, there are various different approaches to using multiple language files in Flash. As a Flash developer, you have a few options to consider. The first is when do you want a user select their language file. Generally, you would want a user to make this selection before the site has loaded, a sort of &#8220;Choose your language&#8221; splash page. This is the most simple approach, as it negates the need to allow for users changing language settings once the website has loaded and its content has displayed. The second is to allow for runtime language changes, although hardly any users would want to change their language after the site has loaded, but there may be a small subset that perhaps make a mistake etc. This approach is a little more complicated, because you need to build into your project the means to let all the elements that can change their language, that they have to change their language, and then also a means for passing around the relevant language data to each of these elements.</p>
<p>Which ever way you approach your language swapping, your interface will need to be flexible enough to accommodate the various different amounts of text it takes to express something like &#8220;About Us&#8221; in different languages.</p>
<p>For this demo I have allowed for runtime language changing, with a default language &#8220;english&#8221; loading. I have not added in any functionality to storing a language selection, but this is simple to add.</p>
<p>Ok, onto the ActionScript.</p>
<p>As I mentioned earlier, the main problem to overcome with runtime language swapping is how to notify all the interested parties in Flash that they need to update their language and dimensions when a user chooses to change language settings. There are various means to approach this, but what it boils down to, is a means to store the language XML in a way that allows for all elements to access it, and a means for notifying all elements that they must change their language file and probably their dimensions. </p>
<p>I&#8217;ve implemented 3 different approaches to changing language files in Flash. Each example is a different means for solving the problem of passing the language files XML to each element and notifying them that they need to change their language settings, along with the means to actually change language files. The different approaches are; Singleton Pattern, Custom Event with params and Observer Pattern. Universal to each example is the use of a simple interface that each ui element implements to guarantee the presence of a <code>setLanguage</code> method in all ui elements that need to change their language. I probably didn&#8217;t really need an interface for this one method, but with a complicated site, with many ui elements, it can be easy to forget a particular method.</p>
<p><strong>1 &#8211; Singleton</strong> Using a Singleton to store language file in a globally accessible point. Singleton classes, allow for what many consider a bit of a <a href="http://www.as3dp.com/2008/11/26/we-don?¢‚Ç¨‚Ñ¢t-need-no-stinkin?¢‚Ç¨‚Ñ¢-singletons-why-to-avoid-the-singleton-pattern-in-actionscript-30-programming/">hack</a>, and that is global access to one class instance. In this implementation, the Singleton is used as an XML loading class, with each class that requires access to the language file importing a reference to this Singletons one and only instance. When a user chooses to change language, an event is dispatched, that all elements are listening for. When this notification event is received, each subscribing item then queries the Singleton for the sites language file, parses this XML data matching its <code>id</code> against the XML elements <code>id</code> code, if a match is found, then that XML fragment is used by the element for its language setting, and the ui updates. This approach works fine, but I don&#8217;t like the long &#8230;. lookups on the Singleton instance and the main deal breaker for me with this implementation is that it locks the site as a whole into accessing this one point for its data. So, if we wanted to provide the language file by some means other than via an external xml file, then we would have some issues. </p>
<p><strong>2 &#8211; Custom Event</strong> Using a custom event with a parameter that allows for us to pass the XML data around the site is the obvious choice I think for sites that need to change language files. The implementation is simple, write a custom event class that allows for us to pass around the XML data from the language file. Have each element that needs to change its language listen for this event, and when a user changes language, simply dispatch the event. When this notification event is received, each subscribing item then queries the events parameter for the sites language file, parses this XML data matching its <code>id</code> against the XML elements <code>id</code> code, if a match is found, then that XML fragment is used by the element for its language setting, and the ui updates. I like this approach, as it decouples the sites ui elements from one particular source for that XML data, it could come from a database, or an external xml file. Either way, the ui elements have no idea where the data comes from, they just listen for an event.</p>
<p><strong>3 &#8211; Observer Design Pattern</strong> Using an <a href="http://www.swinburne.edu.au/design/tutorials/P-flash/T-The-Observer-Design-Pattern-in-Actionscript-3/ID-145/">Observer</a> pattern works fairly well in this situation. Again, the implementation is fairly straightforward, we create an Observer class, which has the usual addSubscriber, removeSubscriber and update methods. Each ui element then subscribes to the observer pattern instance, and when a user changes language files, the observer then loops through its subscribed children, calling each child&#8217;s <code>setLanguage</code> method, passing the sites new XML language data through to each child as a argument of the <code>setLanguage</code> method. This approach works well I think. It still maintains a loose relationship between the ui elements and the language data. The only thing I don&#8217;t really like about this approach, and this design pattern is that it feels like I&#8217;m replicating the basic event dispatcher model in Flash, and so feels redundant. Maybe I&#8217;m missing something. One thing to note, is that I changed the interface for this approach to allow for the <code>setLanguage</code> method to accept XML as an argument.</p>
<p>So, whats the best approach? I tend to prefer using custom events, mostly out of force of habit. I&#8217;m curious to see how other people approach swapping language files in Flash website projects?</p>
<p align="left"><strong>View Example</strong><br />
You can view a pretty simple demo of the event based approach here: <a href="http://www.noponies.com/dev/as3_lang/">http://www.noponies.com/dev/as3_lang/</a></p>
<p align="left"><strong>Source Files</strong><br />
Files for each of the 3 approaches are here: <a class="downloadlink" href="http://www.blog.noponies.com/wp-content/plugins/download-monitor/download.php?id=1" title="Version 1 downloaded 877 times" >Language Swapping Source Files (877) - 2.3 MB</a></p>
<p>Each example is well commented, and the comments should explain most of the functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.noponies.com/2009/01/approaches-for-multi-language-actionscript-3-websites/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
