<?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>Soulwire &#187; Utilities</title>
	<atom:link href="http://blog.soulwire.co.uk/tag/utilities/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.soulwire.co.uk</link>
	<description>Art + Technology</description>
	<lastBuildDate>Mon, 21 Mar 2011 22:27:20 +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>Introducing Springboard</title>
		<link>http://blog.soulwire.co.uk/laboratory/javascript/springboard-javascript-css-html-template</link>
		<comments>http://blog.soulwire.co.uk/laboratory/javascript/springboard-javascript-css-html-template#comments</comments>
		<pubDate>Mon, 21 Mar 2011 22:27:20 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Transmissions]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=1312</guid>
		<description><![CDATA[I love HTML5 Boilerplate and use it a lot as a basis for web projects. Sometimes however, I find it still does a little bit too much for my needs and I end up removing a lot before I can get started. Most importantly for me though, it still currently doesn&#8217;t support building with Google [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/laboratory/javascript/what-the-fuck-is-my-mashup' rel='bookmark' title='Permanent Link: What The Fuck Is My Mashup?'>What The Fuck Is My Mashup?</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/managing-runtime-loaded-dynamic-assets' rel='bookmark' title='Permanent Link: Hello Dynamic Sprite'>Hello Dynamic Sprite</a></li>
<li><a href='http://blog.soulwire.co.uk/laboratory/flash/perlin-noise-flow-field' rel='bookmark' title='Permanent Link: Perlin Noise Flow Field'>Perlin Noise Flow Field</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.soulwire.co.uk/wp-content/uploads/2011/03/springboard.jpg" alt="Springboard is an ultra minimal JavaScript / CSS and HTML project springboard." title="Springboard" width="710" height="250" class="size-full wp-image-1316" /></p>
<p>I love <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://html5boilerplate.com/"  target="_blank">HTML5 Boilerplate</a> and use it a lot as a basis for web projects. Sometimes however, I find it still does a little bit too much for my needs and I end up removing a lot before I can get started.</p>
<p>Most importantly for me though, it still currently doesn&#8217;t support building with <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://code.google.com/closure/compiler/"  target="_blank">Google Closure Compiler</a> which I tend to use both for it&#8217;s advanced code optimisations and for <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://calendar.perfplanet.com/2010/coding-better-object-oriented-javascript-with-closure-compiler/" >coding better Object-Oriented JavaScript</a> (not to mention generating JavaScript documentation from the very same comments I write for the compiler).</p>
<h2>So What&#8217;s Springboard Then?</h2>
<p><a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/Springboard"  target="_blank"><strong>Springboard</strong></a> is an <em>ultra minimal</em> JavaScript / CSS and HTML project template (or <em>springboard</em>).</p>
<p>It features a very useful <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://ant.apache.org/"  target="_blank">ANT</a> build file which, among other things, can:</p>
<ul>
<li>Refactor template files to match your project&#8217;s namespace so you&#8217;re ready to code in seconds</li>
<li>Combine JavaScript and CSS libraries to reduce HTTP requests</li>
<li>Compile JavaScript using the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://code.google.com/closure/compiler/"  target="_blank">Google Closure Compiler</a> <em>(simple or advanced)</em></li>
<li>Minify CSS using the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://developer.yahoo.com/yui/compressor/"  target="_blank">YUI Compressor</a></li>
<li>Generate JavaScript documentation using the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://code.google.com/p/jsdoc-toolkit/"  target="_blank">JSDoc Toolkit</a></li>
<li>Sanitize HTML and inject variables at compile time</li>
</ul>
<p>Also included is a simple JavaScript <strong>Model-View-Controller</strong> (MVC) template (based on <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.alexatnet.com/content/model-view-controller-mvc-javascript"  target="_blank">Alex Netkachov&#8217;s</a>) which can optionally be used as a basis for your project.</p>
<p>Hopefully No fluff &#8211; just the very basics you need to get a project or experiment started.</p>
<p><a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/Springboard"  target="_blank">Check out Springboard on github</a><span id="more-1312"></span></p>
<h2>Quick Setup</h2>
<p>To get started, first clone the repository:</p>
<pre>
cd /your/workspace
git clone git@github.com:soulwire/Springboard.git YourProjectName
</pre>
<p>Run the <strong>setup</strong> task and enter your project&#8217;s namespace when prompted:</p>
<pre>
cd YourProjectName
ant setup
Enter the full project namespace for this project: com.domain.project
</pre>
<p>This will refactor the project template to match your namespace. You&#8217;ll then be given the option to delete the GIT metadata and disconnect from the Springboard repository&#8230;</p>
<p>You can build your project with the default ANT task, <strong>build</strong></p>
<pre>
ant build
</pre>
<p>And when you&#8217;re ready, generate documentation using the <strong>jsdoc</strong> task</p>
<pre>
ant jsdoc
</pre>
<p>You should also have a look at the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/Springboard/blob/master/build.properties"  target="_blank">build.properties</a> file as here you can add your credentials and tweak the various build settings to your taste.</p>
<h2>A Quick Note About Blocks</h2>
<p>Springbard uses HTML comment blocks to figure out how it should build the project. There are different types of blocks you can use:</p>
<ul>
<li><strong>CSS:LIB</strong> &raquo; Third party CSS files (combined and minified)</li>
<li><strong>CSS:SRC</strong> &raquo; Your project&#8217;s styles (combined and minified)</li>
<li><strong>JS:LIB</strong> &raquo; JavaScript dependancies (combined but otherwise left untouched)</li>
<li><strong>JS:SRC</strong> &raquo;  JavaScript source files (combined and compiled)</li>
</ul>
<p>Any linked JavaScript or CSS resources outside of these tags will simply be cloned into the build directory and left untouched for flexibility.</p>
<p>Springboard will look at all of your pages when it builds and combine all files in all blocks of the same type. There is then a generic <strong>document ready</strong> handler, which initialises scripts for a page based on the id tag of it&#8217;s body. This is best illustrated in this <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/Springboard/blob/master/src/js/namespace.project.App.js" >example</a>.</p>
<h2>A Quick Note About Externs</h2>
<p>If you&#8217;ve used the Closure Compiler before, you&#8217;ll be familiar with <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://code.google.com/closure/compiler/docs/api-tutorial3.html#externs"  target="_blank">Externs</a>. Externs tell the compiler not to refactor certain methods and properties, because doing so may break your code if they reference a third party library or code not being compiled. Springboard currently ships with an externs file supporting JQuery 1.5, just to get you going. You can easily generate more for your favorite libraries using <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.dotnetwise.com/Code/Externs/index.html"  target="_blank">this great tool</a> by <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://blog.dotnetwise.com/2009/11/closure-compiler-externs-extractor.html"  target="_blank">Laurentiu Macovei</a> or others like it.</p>
<h2>What Springboard Doesn&#8217;t Do</h2>
<p>The primary intention of Springboard is to provide a simple but powerful project template and build file, which integrates with the Closure Compiler as well as doing the basics which you would expect; such as file concatenation and CSS minification. It&#8217;s intended to be extremely light and minimal, allowing you to take the project kernel forward in whichever way you need; whether it&#8217;s a large site build or a quick JavaScript experiment. I would imagine that future updates will strip it back and optimise it even further, as opposed to adding features.</p>
<p>So to be clear, it is in no way intended as a replacement for the amazing projects out there such as HTML5 Boilerplate; simply an option if you need less rather than more in certain situations.</p>
<p><strong>Now <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/Springboard"  target="_blanl">fork off</a> and start making nice things&#8230;</strong></p>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/laboratory/javascript/what-the-fuck-is-my-mashup' rel='bookmark' title='Permanent Link: What The Fuck Is My Mashup?'>What The Fuck Is My Mashup?</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/managing-runtime-loaded-dynamic-assets' rel='bookmark' title='Permanent Link: Hello Dynamic Sprite'>Hello Dynamic Sprite</a></li>
<li><a href='http://blog.soulwire.co.uk/laboratory/flash/perlin-noise-flow-field' rel='bookmark' title='Permanent Link: Perlin Noise Flow Field'>Perlin Noise Flow Field</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/laboratory/javascript/springboard-javascript-css-html-template/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Dynamic Sprite</title>
		<link>http://blog.soulwire.co.uk/code/actionscript-3/managing-runtime-loaded-dynamic-assets</link>
		<comments>http://blog.soulwire.co.uk/code/actionscript-3/managing-runtime-loaded-dynamic-assets#comments</comments>
		<pubDate>Fri, 21 May 2010 16:56:04 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=1080</guid>
		<description><![CDATA[If you are building a multilingual application (or any application that requires dynamic, runtime loaded assets), swapping and managing assets can easily become tedious and messy. Recently, for projects requiring special characters (such as Chinese, Arabic, Japanese and Hindi) and where dynamic or input text is not required, we have been creating library SWFs for [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/open-source/two-sided-planes-in-flash-player-10' rel='bookmark' title='Permanent Link: Double Sided 3D Plane in FP10'>Double Sided 3D Plane in FP10</a></li>
<li><a href='http://blog.soulwire.co.uk/laboratory/flash/as3-flocking-steering-behaviors' rel='bookmark' title='Permanent Link: Flipping you the Boid'>Flipping you the Boid</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2010/05/DynamicSpriteExample.swf?v=2" rel="lightbox;width=800;height=550;" ><img src="http://blog.soulwire.co.uk/wp-content/uploads/2010/05/dynamic-sprite-demo.jpg" alt="DynamicSprite Demo Application" title="DynamicSprite Demo Application" width="710" height="360" class="size-medium wp-image-1092" /></a></p>
<p>If you are building a multilingual application (or any application that requires dynamic, runtime loaded assets), swapping and managing assets can easily become tedious and messy.</p>
<p>Recently, for projects requiring special characters (such as Chinese, Arabic, Japanese and Hindi) and where dynamic or input text is not required, we have been creating library SWFs for each language and using static textfields to populate content. This saves file size, as unnecessary characters are not embedded, and it eases the process of including different character sets (and even fonts) for each language. It also means that we can include text in the same runtime loaded library as general display assets.<span id="more-1080"></span></p>
<h3>Introducing DynamicSprite</h3>
<p>Using this process, a language specific library SWF is loaded at startup, or at runtime when the users selects a language, and once complete all dynamic assets are updated accordingly. This can get very messy for two reasons. Firstly, it means that each individual asset has to be destroyed and tidied up to release memory before it is replaced. Secondly, if you have a complex application architecture, you will end up dispatching a ton of events and implementing countless methods within every view or component, in order to rollout the update to each desired DisplayObject.</p>
<p>This is where <strong>DynamicSprite</strong> comes in handy. Using DynamicSprite you can effortlessly update any amount of DisplayObjects from any amount of library SWFs at runtime, whilst keeping the SWF loading logic centralised in your proxy or loader class. No events, no asset update APIs in your views and no cleaning up after yourself.</p>
<blockquote><p>Bored? Skip straight to the <a href="#example">examples</a> and download</p></blockquote>
<h3>How It Works</h3>
<p>The concept is very simple. Each instance of DynamicSprite is registered globally at a class level, you need only call a static update method once and all DynamicSprite instances will update themselves automatically. Each instance of DynamicSprite is given a class definition, which can be set or changed at runtime if desired. When a new library is loaded, it will look inside the SWFs <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/system/ApplicationDomain.html"  target="_blank">applicationDomain</a> and if it finds a matching asset, update itself and destroy any existing instances of that asset it might own. You can also create DynamicSprite instances at runtime anytime after an asset library has been loaded &#8211; they will check previously loaded libraries for their class definition when created. This works with any display asset, <strong>Sprites</strong>, <strong>MovieClips</strong>, <strong>Bitmaps</strong> (etc)  &#8211; <strong>BitmapDatas</strong> are also detected and destroyed during the cleanup process.</p>
<p>Furthermore, you can load any amount of libraries per language, at different times if necessary &#8211; DynamicSprites will <em>only update themselves when applicable</em>, making it easy to manage your language specific libraries and even individual libraries per language if you choose to (each type of library has it&#8217;s own ID).</p>
<p>A DynamicSprite instance will also dispatch an event (named <strong>DynamicSprite.INSTANCE_UPDATED</strong>) when it has changed it&#8217;s asset. You can listen for this event if you need to respond to new asset dimensions. You can also listen for two events on the class itself (through a static, encapsulated EventDispatcher) which are dispatched when a library is added or updated but before all instances have changed (<strong>DynamicSprite.LIBRARY_UPDATE_START</strong>) and when all instances have finished updating themselves (if necessary) from the added / updated library SWF (<strong>DynamicSprite.LIBRARY_UPDATE_COMPLETE</strong>).</p>
<h3>Example Implementation<a name="example">&nbsp;</a></h3>
<p>Here is a simple example of how to use DynamicSprite. Although this example only loads one SWF (the code for the multi SWF example is included in the download), it demonstrates how DynamicSprite can also be useful for single language applications where you still choose to load your assets at runtime.</p>
<pre>
public function SimpleExample()
{
	// Create a DynamicSprite instance and provide a class definition for it's asset
	var example : DynamicSprite = new DynamicSprite("assets.example.HelloWorld");
	addChild(example);

	// Load a library SWF
	var loader : Loader = new Loader();
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
	loader.load(new URLRequest("assets_en.swf"));
}

private function onLoadComplete(event : Event) : void
{
	// Call the static update method once to update all DynamicSprites
	DynamicSprite.update("example", LoaderInfo(event.target).content);
}
</pre>
<p>Another advantage of DynamicSprite is that you need not worry about synchronising loading with the update process. Any existing DynamicSprite instance will be updated if required when a library is loaded, however you can also create new instances after a required library has been loaded (useful for highly dynamic content) and any loaded libraries will be searched for matching assets upon creation. This snippet demonstrates this feature.</p>
<pre>
public function SimpleExample()
{
	// Load a library SWF
	var loader : Loader = new Loader();
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
	loader.load(new URLRequest("assets_en.swf"));
}

private function onLoadComplete(event : Event) : void
{
	// Register this library
	DynamicSprite.update("example", LoaderInfo(event.target).content);

	// Creating a DynamicSprite after a library is loaded still works fine
	var example : DynamicSprite = new DynamicSprite("assets.example.HelloWorld");
	addChild(example);
}
</pre>
<h3>Download DynamicSprite</h3>
<p>You can download the DynamicSprite class and the demo below. Also check my code <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://code.google.com/p/soulwire/source/browse/trunk/projects/DynamicSprite/src/uk/co/soulwire/display/DynamicSprite.as"  title="Soulwire SVN repository" target="_blank">repository</a> for updates. If you find any bugs or have any suggestions please leave them in the comments.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=DynamicSprite.zip" class="download" title="DynamicSprite: DynamicSprite is a utility class for easily managing runtime loaded assets"  rel="nofollow"><strong>Download:</strong> DynamicSprite</a>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/open-source/two-sided-planes-in-flash-player-10' rel='bookmark' title='Permanent Link: Double Sided 3D Plane in FP10'>Double Sided 3D Plane in FP10</a></li>
<li><a href='http://blog.soulwire.co.uk/laboratory/flash/as3-flocking-steering-behaviors' rel='bookmark' title='Permanent Link: Flipping you the Boid'>Flipping you the Boid</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/actionscript-3/managing-runtime-loaded-dynamic-assets/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

