<?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>Huy Dinh &#187; trick</title>
	<atom:link href="http://huydinh.co.uk/blog/tag/trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://huydinh.co.uk/blog</link>
	<description>Just 8 bit crazy about coding</description>
	<lastBuildDate>Sat, 23 Jan 2010 11:47:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Time saving hack!</title>
		<link>http://huydinh.co.uk/blog/2007/11/15/5/</link>
		<comments>http://huydinh.co.uk/blog/2007/11/15/5/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 20:06:55 +0000</pubDate>
		<dc:creator>Huy Dinh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://huydinh.co.uk/blog/?p=5</guid>
		<description><![CDATA[I was working on Axe, adding an extra link into the bottom nav... simple task!
...or it should be... but the system wasn't designed properly, links were in the wrong places in the database, the flash parsed the xml using absolute positions. The first 3 elements were ignored, they're the main sections, the next 3 were [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on Axe, adding an extra link into the bottom nav... simple task!</p>
<p>...or it should be... but the system wasn't designed properly, links were in the wrong places in the database, the flash parsed the xml using absolute positions. The first 3 elements were ignored, they're the main sections, the next 3 were the original bottom navs, a few more elements make up forms and other areas of the site, and the last, which I've just added sits at position 11.</p>
<p>The original code looks similar to this:</p>
<div class="igBar"><span id="lactionscript-3"><a href="#" onclick="javascript:showPlainTxt('actionscript-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-3">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;color:#800000;">3</span>; i &amp;lt;<span style="color: #cc66cc;color:#800000;">6</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> element:<span style="color: #0066CC;">XMLNode</span> = <span style="color: #0066CC;">xmlnode</span>.<span style="color: #0066CC;">childNodes</span><span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// blah blah</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The best practice thing to do would be to move all the bottom nav links  into one section, but as usual, time, money, client - all the usual reasons means that the work had to be done yesterday, I needed to find a quick hack.</p>
<p>So this is what I came up with:</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> elementIDs:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;color:#800000;">3</span>, <span style="color: #cc66cc;color:#800000;">4</span>, <span style="color: #cc66cc;color:#800000;">11</span>, <span style="color: #cc66cc;color:#800000;">5</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> elementIDs<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> element:<span style="color: #0066CC;">XMLNode</span> = <span style="color: #0066CC;">xmlnode</span>.<span style="color: #0066CC;">childNodes</span><span style="color: #66cc66;">&#91;</span> elementIDs<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// blah blah</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hard coding the posisions into an array allowed me to place the elements in any order I like, it's a good thing because the client wanted the new link between existing links.</p>
<p>Quite a neat trick I think!</p>
]]></content:encoded>
			<wfw:commentRss>http://huydinh.co.uk/blog/2007/11/15/5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
