<?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>Nikita Dudnik &#187; snippet</title>
	<atom:link href="http://nikitadudnik.com/blog/tag/snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://nikitadudnik.com/blog</link>
	<description>Random casual.</description>
	<lastBuildDate>Thu, 02 Jul 2009 15:40:59 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gaia Framework in real life application</title>
		<link>http://nikitadudnik.com/blog/2009/05/gaia-framework-in-real-life-application/</link>
		<comments>http://nikitadudnik.com/blog/2009/05/gaia-framework-in-real-life-application/#comments</comments>
		<pubDate>Sat, 23 May 2009 21:59:46 +0000</pubDate>
		<dc:creator>Nikita</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[gaia framework]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://nikitadudnik.com/blog/?p=108</guid>
		<description><![CDATA[Intro
Every experienced flash designer or developer knows flash is special. It’s a half visual, half code based environment. At this time there are several ways to make complete flash projects in a pure coding IDE, but many projects are too visual and rely on Flash IDE. And even the greatest coding IDE won’t save you [...]]]></description>
			<content:encoded><![CDATA[<h2>Intro</h2>
<p>Every experienced flash designer or developer knows flash is special. It’s a half visual, half code based environment. At this time there are several ways to make complete flash projects in a pure coding IDE, but many projects are too visual and rely on Flash IDE. And even the greatest coding IDE won’t save you from the tedious work of setting up the structure of your project and handling some typical tasks like assets preloading or deep-linking.</p>
<p>There were some helpful libraries and frameworks but they couldn’t write the code for you and were scary for most visual arts people.</p>
<p>Now there is a solution that fits both designers and developers and <strong>writes</strong> at least part of the code of your project automatically. It’s named <strong>Gaia Framework</strong>.</p>
<blockquote><h4>Standart Gaia Framework workflow</h4>
<ol>
<li>Create new project using Gaia Framework panel.</li>
<li>Edit site.xml.</li>
<li>Scaffold using Gaia Framework panel.</li>
<li>Edit resulting flas if you are a designer or AS classes if you are a developer or do both for different pages. Don’t forget to remove scaffolding code.</li>
<li>Publish your project.</li>
</ol>
</blockquote>
<h2>Overview of The Framework</h2>
<p>Gaia Framework is a solution composed of AS library and a nice scaffolding engine built right inside Flash IDE as an installable extension. It supports both Actionscript 2.0 and 3.0.</p>
<p>The scaffolding saves a lot of time by removing a tedious and repeating steps from your work.</p>
<p>Out of the box you have:<br />
- creating project structure and files automatically;<br />
- loading and handling of different types of assets;<br />
- deep-linking and SEO;<br />
- cross platform middle mouse button support;<br />
- transitions handling.</p>
<h2>My goal</h2>
<p>My goal was to create a cd presentation with all the data being loaded from external files. I was really short on time and input from the client. I had three days to roll out something working and editable to improve it after first showcase to the client. It was a "do or die trying" situation. I had already looked into Gaia Framework so I grabbed last version and started to work.</p>
<p>I had no limitations on flash version and used AS 3.0 targeting Flash Player 10.</p>
<h2>The work</h2>
<h3>Page templates</h3>
<p>First of all I created presentation base. The project had many pages with similar layout but different data. Officially there’s no templating in Gaia. I just used same swf for similar pages and it worked. Probably this broke SEO and deeplinking but it was ok ‘cause I was targeting standalone flash projector.</p>
<p>After that I had all my data ready to use. No fuss with preloading and parsing but ready to use texts, pictures and sounds all placed in the context of their page. I’ll get back to that later. There are were some navigation to create.</p>
<h3>Global navigation</h3>
<p>Every page in Gaia Framework has an unique path. You could get what page is on the screen (current visible page) using Gaia.api.getCurrentBranch() and initiate transition to any other page using Gaia.api.goto(branch:String). This two commands made creating global navigation a snap.</p>
<h3>Breadcrumb Navigation</h3>
<p>The client asked for breadcrumb navigation. I made a quick and simple version using flash ability to handle clicks on the text field links.
<pre class="brush: as3;">private function onLink(e:TextEvent = null):void
{
Gaia.api.goto(e.text.split('.').join('/'));
//Fix inability to pass slashes in link event parameters
}
private function updateBreadcrumb(e:Event = null):void
{
var s:String = &quot;&quot;;
var curr:IPageAsset = Gaia.api.getPage(Gaia.api.getCurrentBranch());

/* Below is all the magic to create breadcrumb navigation text
Fill the breadcrumb until the page with id == “nav” is reached. |
It’s the highest one in the site tree. */
while (curr.id != &quot;nav&quot;) {
s= &quot;&gt; &lt;a href='event:&quot;+curr.branch.split('/').join('.')+&quot;'&gt;&quot;+curr.title+&quot;&lt;/a&gt; &quot; + s;
curr = curr.getParent();
}
breadcrumb.htmlText = s;
}</pre>
<p>The navigation was working well I moved to creating inner pages.</p>
<h3>Simple pages</h3>
<p>Some pages were just a picture with a scrollable text field. These pictures were not intended to be loaded from external files and I just embedded them right into flas. The texts were dynamic and due to automatic preloading they were already accessible on the corresponding pages.</p>
<p>The part of site.xml defining one of the text assets.</p>
<pre class="brush: xml; light: true;">&lt;page id=&quot;contacts&quot; src=&quot;contacts.swf&quot; title=&quot;Contacts&quot; menu=&quot;true&quot; bytes=&quot;79794&quot;&gt;
     &lt;asset id=&quot;desc&quot; src=&quot;data/contacts.txt&quot; bytes=&quot;1102&quot;/&gt;
&lt;/page&gt;</pre>
<p>This makes the content of contacts.txt accessible on the page with id == “contacts” using IText(assets.desc).text</p>
<p>IText is an interface for text assets. It is just one kind of many GAIA asset types. Also from the version 3.1.4 you can add your custom assets.</p>
<h3>Projects List page</h3>
<p>The projects page contained a list of thumbnail pictures of projects with short text description. It was easy to get the list out of the current page children array. The only problem was their order. It was random due to a hash nature of this property.</p>
<p>I managed to get list of children pages in order using code below.</p>
<pre class="brush: as3; light: true;">var id_check:String = page.id;
// current page id
var xml_list:XMLList = xml..page.(@id == id_check).page.@id;
// current page children ids in the xml order
var xx:XML;
for each (xx in xml_list) {
trace(page.children[xx].title);
//check the output. absolutely correct order!
}</pre>
<h3>Back button</h3>
<p>It was easy to implement using Gaia.api.getCurrentBranch();<br />
Below is what happens when the back button is clicked. This code forms the path and executes a transition to the current page’s parent.</p>
<pre class="brush: as3; light: true;">private function goUp(e:Event):void
{
var curr:String = Gaia.api.getCurrentBranch();
var temp:Array = curr.split('/');
temp.pop();
trace(temp.join('/'));
Gaia.api.goto(temp.join('/'));
}</pre>
<h3>Image gallery component</h3>
<p>Some pages had image gallery. I used same gallery component everywhere.<br />
Using (parent as IPage).page.assets I could access already preloaded images of the corresponding page.</p>
<h2>Conclusions</h2>
<p>Gaia Framework greatly speeds up development of every project with tree like structure. It shortens the time of setting up the project from days to hours. If your are designer you’ll like how many technical aspects it automates and makes possible. If you are developer you’ll like how much time it saves. If you are a team you’ll like how modular and easy to understand both for designer and developer your project is.</p>
<p>Gaia Framework is a valuable addition to every flash site or presentation creator workflow.</p>
<h2>Links</h2>
<p><a href="http://www.gaiaflashframework.com/screencasts/lesson1/">Official screencast</a></p>
<p><a href="http://www.gaiaflashframework.com/wiki/index.php?title=Main_Page">Documentation</a></p>
<p><a href="http://www.gaiaflashframework.com/index.php">Site and download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nikitadudnik.com/blog/2009/05/gaia-framework-in-real-life-application/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
