<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>RIA</title>
	
	<link>http://ria.creuna.com</link>
	<description>rich media R&amp;D</description>
	<lastBuildDate>Wed, 11 Aug 2010 08:39:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/riacreuna" /><feedburner:info uri="riacreuna" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/riacreuna" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsalloy.com/?rss=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.newsalloy.com/subrss3.gif">Subscribe with NewsAlloy</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://download.attensa.com/app/get_attensa.html?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.attensa.com/blogs/attensa/WindowsLiveWriter/BadgeredintoBadges_10C02/attensa_feed_button5.gif">Subscribe with Attensa for Outlook</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Friacreuna" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Flash : Inverse masking</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/2Oi1h8UB6gQ/</link>
		<comments>http://ria.creuna.com/2010/08/flash-inverse-masking/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 08:38:03 +0000</pubDate>
		<dc:creator>Anders Figenschow</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[inverse masking]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=600</guid>
		<description><![CDATA[To apply inverse masking in flash as3, you can achieve this by applying BlendModes. Here is how: 1) apply flash.display.BlendMode.LAYER to the parent object 2) apply flash.display.BlendMode.ERASE to your inverse mask object 3) Awesome.]]></description>
			<content:encoded><![CDATA[<p>To apply inverse masking in flash as3, you can achieve this by applying BlendModes.</p>
<p>Here is how:<br />
1) apply flash.display.BlendMode.LAYER to the parent object<br />
2) apply flash.display.BlendMode.ERASE to your inverse mask object<br />
3) Awesome.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/2Oi1h8UB6gQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2010/08/flash-inverse-masking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2010/08/flash-inverse-masking/</feedburner:origLink></item>
		<item>
		<title>Flash : Objects get blurry after rotating in 3D-space</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/TUkLjeekcOs/</link>
		<comments>http://ria.creuna.com/2010/07/flash-objects-get-blurry-after-rotating-in-3d-space/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 07:45:15 +0000</pubDate>
		<dc:creator>Anders Figenschow</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=595</guid>
		<description><![CDATA[After working on a project for a while utilizing native as3 3d space, moving objects along the z axis, rotation and having the time of my life, I realized that as soon as you try something stupid like that, every object will be blurred even if you reset their position to their original 2D positions, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ria.creuna.com/wp-content/uploads/2010/07/blurry.jpg"><img class="alignnone size-medium wp-image-597" title="blurry" src="http://ria.creuna.com/wp-content/uploads/2010/07/blurry-300x200.jpg" alt="Blurry Blur Blur" width="300" height="200" /></a></p>
<p>After working on a project for a while utilizing native as3 3d space, moving objects along the z axis, rotation and having the time of my life,<br />
I realized that as soon as you try something stupid like that, every object will be blurred even if you reset their position to their original 2D positions, with no rotation, and the z position set to 0.</p>
<p>The designers would, of course, have none of it.</p>
<p>If any of you have encountered this issue and need a workaround, here is one:</p>
<p>1) remember your objects x/y positions<br />
2) set your matrix3D to null  (someObject.transform.matrix3D = null)<br />
this will place your objects in your corner, so you need to<br />
3) reset x/y on your objects.  you know them from 1)</p>
<p>For example:</p>
<p>var position:Point = new Point(content.x, content.y);<br />
content.transform.matrix3D = null;<br />
content.x = position.x;<br />
content.y = position.y;</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/TUkLjeekcOs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2010/07/flash-objects-get-blurry-after-rotating-in-3d-space/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2010/07/flash-objects-get-blurry-after-rotating-in-3d-space/</feedburner:origLink></item>
		<item>
		<title>My programming philosophy</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/iXqCuzeat1c/</link>
		<comments>http://ria.creuna.com/2010/02/my-programming-philosophy/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 13:23:04 +0000</pubDate>
		<dc:creator>Andreas Rønning</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=587</guid>
		<description><![CDATA[I&#8217;ve been thinking about writing this post for a while, but every time i started it felt like i was trying to teach a crowd that already knows better than me, and that&#8217;s a level of arrogance beyond even me. But i can&#8217;t help but feel there is something to how i do things that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about writing this post for a while, but every time i started it felt like i was trying to teach a crowd that already knows better than me, and that&#8217;s a level of arrogance beyond even me.</p>
<p>But i can&#8217;t help but feel there is something to how i do things that must be at the very least affirming to some developers out there. Flash developers often work alone or in small groups, and few really have a big community to hang out with. It creates an atmosphere where you are never really comfortable with your own skill level, and for me at least it fostered a belief that everybody out there were doing rocket science and I was still building Lego cars and didn&#8217;t even bother to make the colors uniform.</p>
<p>I&#8217;ll write down some specific beliefs that have helped me a lot.</p>
<p><span id="more-587"></span></p>
<h3>Object-oriented programming is there to make <em>your</em> life easier, not the machine&#8217;s.</h3>
<p>When AS2 first dropped on us and i was firmly embedded in AS1 and prototype hacking, i could barely grasp the need for inheritance, and interfaces came much later. I was comfortable with functions-as-classes, long rambling frame scripts and include statements, and i felt like i was on top of the platform and what it could do.</p>
<p>Every time i tried to read about OOP i would be drowned in talk about design patterns and other things that are only really material from a philosophical point of view, but are often portrayed as fact, and digging your way through the religious forum conflicts you find out there can serve as a royal boot to the head if you&#8217;re trying to find your way in. My first bumbling steps into OOP were moving from include statements and frame scripts into a single frame script that instantiated an Application class. The actual difference was semantic at best, but it felt good  to test the waters.</p>
<p>The actual BOOM moment where i suddenly &#8220;got it&#8221; was when i started doing application design on paper. Previously I&#8217;d drawn visual states -Big boxy wireframes and rough line charts- and eyeballed the code from there, which was good while i was in the moment, but hell to return to a while later. When putting down thoughts i stopped writing MovieClip or Button, String and Array, and instead started naming things just what i physically imagined them to be. It&#8217;s an obvious thing in retrospect, but much like understanding Arrays and other such abstractions that no longer name objects, it was a huge mental tectonic shift. An image isn&#8217;t a MovieClipLoader in a MovieClip, it is simply an <em>Image</em>.  The change in work process was literally over night. I stopped starting at Application.as and working my way outwards. I started creating dozens of stub classes simply to have the names and <em>concepts</em> in place before i began the actual coding.</p>
<p>It dawned on me that OOP didn&#8217;t just let me apply programming principles i felt were beyond my need. It let me alter the fundamental constructs of the <em>programming language</em>. By compartmentalizing problems, i had been given the opportunity to break an application down into dozens of individual small problems that were typically easily surmountable, that in concert could be used to solve even bigger problems. A hypothetical image gallery is an ImageGallery loading xml into an ImageList containing ImageListItems consisting of an Image and an ImageInfoOverlay. I don&#8217;t have to worry about how the Image is displayed in the ImageList, the Image handles that. I don&#8217;t have to worry about what information to display about an image on mouseover, the ImageInfoOverlay does that.  Mentally, i&#8217;m not thinking about abstractions like sprites or arrays anymore; Those are simply words i use to <em>describe</em> a concept. The <em>concept</em> is what actually matters.</p>
<p>In summary: OOP lets you dictate the language in which you write your application. It is this key principle that lets a developer move from one OOP language to another with relative ease. I shudder to think what i would have gone through trying to learn C++ or C# with only AS1 under my belt. If i have any specific wisdom I&#8217;d like to impart on a developer new to OOP concepts, it would be this: Make it easy for yourself first, and you&#8217;ll be typing what is natural to you.</p>
<h3>It is okay to have many classes, it&#8217;s okay to be verbose, and it&#8217;s okay to be an idiot</h3>
<p>Actually, the more classes the better, because with every class you are bending the language semantics to your will. This comes down to the absolute basics. Say you are implementing a geometry algorithm for the first time. The document you are learning from refers to points as vertices. At this point, i would typically create a class named Vertex that simply extends Point and does nothing more than call super(). All i have done here is change the name of the Point class. Why? Because it&#8217;s one less step for my brain to walk while i&#8217;m learning this new algorithm.</p>
<p>I&#8217;m an artist first. I began as a designer, I consider myself a musician first, and i have the attention span of a cat. In spite of this, i find programming hugely empowering and satisfying. It wouldn&#8217;t be half as fun if i wasn&#8217;t able to recognize that my brain simply works in visual and physical concepts, not deep abstraction. It&#8217;s a common saying that programming is like explaining to a really, really dumb person how to do something, but i think it&#8217;s important to realize that you are also talking to yourself most of the time.</p>
<p>I&#8217;m comfortable with my own inability to work effectively with heavily abstracted patterns like MVC, because they don&#8217;t speak well to me as a <em>person</em>. My goal is to complete a task and ship a product i feel good about, not successfully apply a design pattern someone else put together in their own language. Which brings us to the next point.</p>
<h3>If it floats your boat&#8230;</h3>
<p>Design patterns can be absolutely wonderful things, but they should in my opinion be read as philosophies, not sets of rules. It is entirely possible to work within a very abstract design pattern and not be aware that you are doing so. I cherry pick concepts from patterns that i like and apply liberally with little real concern beyond getting the job done with a minimum of pain; Patterns are typically merely solutions to generic problems, and there is no reason to be afraid of them, or treating them like a set of commandments.</p>
<p>You&#8217;ll find a lot of technical developers with a very technical point of view that will, for instance, decry the merits of a singleton, while as a developer under stress a singleton can be an enormous timesaver. Don&#8217;t let the philosophical debate around patterns stop you from reading into them and taking with you what you need. In the end it should all help YOU be a better and more effective developer and prevent headaches, not the other way around. My first venture into patterns, a rudimentary exploration of MVC, resulted in me actually feeling dumber than before, and was a serious setback for me as someone getting comfortable with new concepts.</p>
<h3>Fuzzy coding is fine within a known system</h3>
<p>Don&#8217;t be afraid to create utilities for speeding up your workflow, even if it does mean doing something &#8220;dumb&#8221;. Unless it&#8217;s realtime or inner-loop code, optimization isn&#8217;t something you should even have to consider for solving menial tasks. Here&#8217;s one of my favorite utilities of recent:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/**<br />
* Enumerates embedded fonts as an array of string fontnames<br />
* @param enumerateDeviceFonts<br />
* @return<br />
*/</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> enumerateFonts<span style="color: #66cc66;">&#40;</span>enumerateDeviceFonts:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> a:<span style="color: #0066CC;">Array</span> = <span style="color: #0066CC;">Font</span>.<span style="color: #006600;">enumerateFonts</span><span style="color: #66cc66;">&#40;</span>enumerateDeviceFonts<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> out:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;<br />
<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> fnt:<span style="color: #0066CC;">Font</span> <span style="color: #b1b100;">in</span> a<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
out.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>fnt.<span style="color: #006600;">fontName</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #b1b100;">return</span> out;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #808080; font-style: italic;">/**<br />
* Looks through embedded fonts and gets the most similar font name to the argument<br />
* @param&nbsp; &nbsp; fontsearch<br />
* @return<br />
*/</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getFontBySimilarFontName<span style="color: #66cc66;">&#40;</span>fontsearch:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> fonts:<span style="color: #0066CC;">Array</span> = enumerateFonts<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> fontName:<span style="color: #0066CC;">String</span> <span style="color: #b1b100;">in</span> fonts<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>fontName.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span>fontsearch.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> fontName;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Found no similar fonts&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Say i want to set up a TextFormat with a font name. I know the font is called &#8220;whateverfont&#8221;, but the actual embedded name of the font if i want to refer to it embedded is case intensive and may have spaces or extra characters that I&#8217;m not aware of, such as Whatever Font STD. Before, this would entail using an enumerateFonts call to grab the font objects, and then manually look through them to get the correct font name. With this utility, i simply call FontUtils.getFontBySimilarFontName(&#8220;whatever&#8221;). It allows me to be fast and loose, at the cost of a couple of extra loops when it gets called, which is ONCE when i declare the TextFormat. This is a trade-off I&#8217;m very ready to make, and I don&#8217;t see why I shouldn&#8217;t be allowed to.</p>
<p>You should allow yourself to be fuzzy and loose when coding, because it, again, takes your mind off the menial boredom and keeps your eyes on the ball.</p>
<h3>Have fun</h3>
<p>Don&#8217;t let nerds and sourpusses bring you down. Programming isn&#8217;t &#8220;for smart people&#8221;. It&#8217;s just another language, albeit one where clarity is the point and not the model. Don&#8217;t let high-end tech-talk make you feel poorly about your skills. Don&#8217;t be afraid to mix and blend. Think naturally. When you are starting up, think about the product you are making and not the individual problems within it; You can solve each problem on its own. Whatever way you solved the problem, the problem remains solved.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/iXqCuzeat1c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2010/02/my-programming-philosophy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2010/02/my-programming-philosophy/</feedburner:origLink></item>
		<item>
		<title>Make a happy Christmas tree with our supercool Christmas card generator!</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/I-Tfe6Je01s/</link>
		<comments>http://ria.creuna.com/2009/12/make-a-happy-christmas-tree-with-our-supercool-christmas-card-generator/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 13:54:57 +0000</pubDate>
		<dc:creator>Anders Figenschow</dc:creator>
				<category><![CDATA[Concept development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Inspiration]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=580</guid>
		<description><![CDATA[Today we launched our super hip Christmas card generator, where you can draw a tree, decorate it, and send it to a friend. The tree is then planted in our mysterious Christmas tree mountain world for everyone to see. In these green times &#8211; make a virtual tree and share the love here:  http://creunaclient.no/jul/ We [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_581" class="wp-caption alignnone" style="width: 310px"><a title="Click here for magical fun!" href="http://creunaclient.no/jul/" target="_blank"><img class="size-full wp-image-581 " title="Click here for magical fun in the super exciting world of virtual Christmas trees!" src="http://ria.creuna.com/wp-content/uploads/2009/12/xmastree.png" alt="Magical world of virtual trees" width="300" height="214" /></a><p class="wp-caption-text">Magical world of virtual trees</p></div>
<p>Today we launched our super hip Christmas card generator, where you can draw a tree, decorate it, and send it to a friend.<br />
The tree is then planted in our mysterious Christmas tree mountain world for everyone to see.</p>
<p>In these green times &#8211; make a virtual tree and share the love here:  <a title="Creuna Christmas Card Generator" href="http://creunaclient.no/jul/" target="_blank">http://creunaclient.no/jul/</a></p>
<p>We are looking forward to seeing YOUR tree in the magical forest of virtual Christmascards.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/I-Tfe6Je01s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/make-a-happy-christmas-tree-with-our-supercool-christmas-card-generator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/make-a-happy-christmas-tree-with-our-supercool-christmas-card-generator/</feedburner:origLink></item>
		<item>
		<title>Autumn music</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/CWtBktIMmQM/</link>
		<comments>http://ria.creuna.com/2009/12/more-particle-mayhem/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 04:22:33 +0000</pubDate>
		<dc:creator>Andreas Rønning</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[max richter]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[sync effects]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=572</guid>
		<description><![CDATA[Another quick one this. I stumbled across another one of those nostalgic particle tutorials that showed how to make a waterfall. It was really basic stuff, but inspiring nonetheless. Being a jerk, i decided to make the ultimate particle waterfall effect, what with displacement maps and diffraction and all that good stuff. It turns out, [...]]]></description>
			<content:encoded><![CDATA[<p>Another quick one this. I stumbled across another one of those nostalgic particle tutorials that showed how to make a waterfall. It was really basic stuff, but inspiring nonetheless. Being a jerk, i decided to make the ultimate particle waterfall effect, what with displacement maps and diffraction and all that good stuff.</p>
<p>It turns out, however, that this is very boring to do.</p>
<p>Instead, as i was playing around with the particles and various combinations and sequences of blend modes, I started listening to my current favorite contemporary composer, Max Richter, and I wound up making this thing instead. (Beware! Music! Also, CPU murder!)<br />
<span id="more-572"></span><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_WaterfallXP_803691978"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://andreas.creunaclient.no/blogfiles/autumnmusic/WaterfallXP.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://andreas.creunaclient.no/blogfiles/autumnmusic/WaterfallXP.swf"
			name="fm_WaterfallXP_803691978"
			width="500"
			height="500">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>This kind of thing just happens naturally when I start playing around. It&#8217;s not particularly complex technically, more a question of constantly tweaking values until you feel happy. In ActionScript terms, it&#8217;s a linked list object pool of 100k particles, a double buffer of bitmapdata, two blendmodes and a blurfilter, as well as a few tweaks timed to trigger at moments in the music. A mouse trailer tracks the, er, mouse, and samples colors from an underlying image. I don&#8217;t put much thought into the images i use for backgrounds, they&#8217;re more color palettes than anything else. The result in this case is a little chaotic i think, but the point for me was the music. I wanted something hypnotic and organic, sort of like thousands of leaves blowing in the wind, and i wanted it to lift and fall with the music. I think i did that pretty okay for a first ;-)</p>
<p>The music is Autumn Music 2 by Max Richter off his fantastic album <a href="http://www.amazon.com/Memoryhouse-Max-Richter/dp/B001EGS4ZW" target="_blank">Memoryhouse</a>.</p>
<p>I&#8217;m still not 100% sure it&#8217;s a good idea to electrocute your eyes every few seconds. Feel free to complain about any headaches!</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/CWtBktIMmQM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/more-particle-mayhem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/more-particle-mayhem/</feedburner:origLink></item>
		<item>
		<title>RSS Feeds Moved</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/sv1bvSoJfQc/</link>
		<comments>http://ria.creuna.com/2009/12/rss-feeds-moved/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 09:47:31 +0000</pubDate>
		<dc:creator>Martin Jacobsen</dc:creator>
				<category><![CDATA[Creuna]]></category>
		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=564</guid>
		<description><![CDATA[Just a real quick PSA to let you know that we&#8217;ve moved the RSS feeds over to feedburner.com. I believe the transfer should be seamless, but just in cased someone feel stranded, just unsubscribe and re-subscribe to fix any problems. We apologize for any inconvenience but we&#8217;re stat-whores, so we need to satisfy our curiosity. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="right" src="http://ria.creuna.com/wp-content/uploads/2009/12/feed_reader.png" alt="Feed Reader" height="253" width="272"></p>
<p>Just a real quick <abbr title="Public Service Announcement">PSA</abbr> to let you know that we&#8217;ve moved the RSS feeds over to <a href="http://feedburner.google.com/">feedburner.com</a>. I believe the transfer should be seamless, but just in cased someone feel stranded, just unsubscribe and re-subscribe to fix any problems.</p>
<p>We apologize for any inconvenience but we&#8217;re stat-whores, so we need to satisfy our curiosity.</p>
<p>That&#8217;s all.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/sv1bvSoJfQc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/rss-feeds-moved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/rss-feeds-moved/</feedburner:origLink></item>
		<item>
		<title>Ada: We salute you – The worlds First Programmer</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/esJS_cLx8C0/</link>
		<comments>http://ria.creuna.com/2009/12/ada-we-salute-you/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 09:12:12 +0000</pubDate>
		<dc:creator>Martin Jacobsen</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[interesting]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=556</guid>
		<description><![CDATA[This article was cross-posted on ctrloptcmd.com; Martins personal blog. Hear ye; Codesmiths and Script Artisans. Nay; Hear ye all who labour with keyboard and mouse, for you owe a debt to the singular person we commemorate today. Ahem. On this day, the 10th of december, a shockingly large number of years ago the First Programmer [...]]]></description>
			<content:encoded><![CDATA[<p><small>This article was cross-posted on <a href="http://ctrloptcmd.com/" title="RIA">ctrloptcmd.com</a>; Martins personal blog.</small></p>
<hr />
</p>
<h3>Hear ye; Codesmiths and Script Artisans. Nay; Hear ye all who labour with keyboard and mouse, for you owe a debt to the singular person we commemorate today.</h3>
<p>Ahem. On this day, the 10th of december, a shockingly large number of years ago the <strong>First Programmer</strong> was born. If this story isn&#8217;t old hat to you you might be surprised to learn the bearer of this distinct honorific was born in 1815 in London. <br />What might also surprise you, a pleasant surprise, is that she was a woman.</p>
<h2>Ada Lovelace</h2>
<p><a href="http://en.wikipedia.org/wiki/File:Ada_Lovelace.jpg" title="File:Ada Lovelace.jpg - Wikipedia, the free encyclopedia"><img src="http://ctrloptcmd.com/wp-content/uploads/2009/12/ada_lovelace_the_worlds_first_programmer.png" alt="Ada Lovelace - The worlds First Programmer" height="400" width="550"></a><br />
Born Augusta Ada Byron she was the daughter of <a href="http://en.wikipedia.org/wiki/George_Gordon_Byron,_6th_Baron_Byron" title="George Gordon Byron, 6th Baron Byron - Wikipedia, the free encyclopedia">Lord Byron</a> (he of poetry fame and infamy) and Anne Isabella Milbanke. <br />Her mother, who was not impressed with Lord Byrons debauchery and loose morals focused her education on mathematics and science, forbidding her to pursue the social sciences in order to prevent her from becoming a bohemian bum like her father. At seventeen Ada showed remarkable aptitude in mathematics and her interest continued even after her marriage; Contrary to the custom of women at the time.</p>
<p><a href="http://en.wikipedia.org/wiki/Charles_Babbage">Charles Babbage</a>, her friend and fellow math wiz (amongst other things) had been working with logarithms and in an effort to remove uncertainty and human errors in this line of work he conceived of a Mechanical Computing Device to replace the traditional system of the time which were human clerks with the title &#8216;Computer&#8217;; &#8220;One who computes&#8221;.</p>
<p>Babbage; For all his genius ground work, was severely limited in his conception of the computer. He saw it as a mechanical means to execute mathematical operations with high precision. Enter our heroine Lady Lovelace.</p>
<p>In 1842-43 she translated a memoir of italian mathematician <a href="http://en.wikipedia.org/wiki/Federico_Luigi,_Conte_Menabrea" title="Federico Luigi, Conte Menabrea - Wikipedia, the free encyclopedia">Luigi Menabrea</a> on Babbages conceptual machine. Her additional notes were longer than the memoir itself, and substantially more visionary in nature. In these notes she conceived of making the analytical device accept, comprehend and execute commands; In essence creating the first programming language.</p>
<p>Babbage was never able to actually create his machine, and Ada never got to see the fruits of her labour. Vindicated in history her notes are published and distributed today, she has post-humously been awarded a medal from The British Computer Society and the contemporary programming language <a href="http://en.wikipedia.org/wiki/Ada_(programming_language)" title="Ada (programming language) - Wikipedia, the free encyclopedia">Ada</a> is named in her honor. As a side note; Babbages machine have later been constructed as per his notes and was found to be highly accurate at mathematical operations.</p>
<h2>Why should we care?</h2>
<p><a href="http://en.wikipedia.org/wiki/File:Ada_lovelace.jpg" title="File:Ada lovelace.jpg - Wikipedia, the free encyclopedia"><img src="http://ctrloptcmd.com/wp-content/uploads/2009/12/adasmall_2.png" class="right" alt="Adasmall 2" height="309" width="250"></a> Geek holidays are great, and we need more of them. But if you look at the notable dates and personalities in this industry there are two factors that separate Ada Lovelace from the rest. <br />Firstly; she is <strong>by far</strong> one of the strongest examples of the long heritage of brilliant people on whose shoulders we stand to todays technology. Secondly: and it&#8217;s sad that this should matters, but it remains to be a factor and an important one at that; She is a woman. Our industry is heavily male-dominated. Not only in our workplaces but also in our heroes and legends.<br />I mean no slight to <a href="http://en.wikipedia.org/wiki/Alan_Turing" title="Alan Turing - Wikipedia, the free encyclopedia">Alan Turing</a>, <a href="http://en.wikipedia.org/wiki/Steve_Wozniak" title="Steve Wozniak - Wikipedia, the free encyclopedia">Steve Wozniak</a>, <a href="http://en.wikipedia.org/wiki/Tim_Berners-Lee" title="Tim Berners-Lee - Wikipedia, the free encyclopedia">Sir Tim Berners-Lee</a> and their esteemed co-idols, but by god; this sausage party needs some dames.</p>
<p>Searching for &#8220;Ada Lovelace&#8221; yields among other links a page that declares 24th of March to be <a href="http://findingada.com/" title="Finding Ada — Bringing women in technology to the fore">Ada Lovelace Day</a> and ask bloggers to pledge to write a post about Ada. Since the site seemed defunct after this date I propose that Ada Lovelace Day should be her birthday; the 10th of December and that we geeks make room for it among <a href="http://en.wikipedia.org/wiki/Towel_Day" title="Towel Day - Wikipedia, the free encyclopedia">Towel Day</a>, <a href="http://www.zeldman.com/2007/11/19/blue-beanie-day/" title="Blue Beanie Day  &#8211;   Jeffrey Zeldman Presents The Daily Report">Blue Beanie Day</a> and <a href="http://en.wikipedia.org/wiki/Pi_Day" title="Pi Day - Wikipedia, the free encyclopedia">PI Day</a> so this amazing historical figure gets the attention she deserves.</p>
<p>Who&#8217;s with me?</p>
<h3>Further studies.</h3>
<ul>
<li>The wikipedia article on <a href="http://en.wikipedia.org/wiki/Ada_Lovelace" title="Ada Lovelace - Wikipedia, the free encyclopedia">Ada Lovelace</a> from which most of this post was taken</li>
<li>iTunes link for &#8220;<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?i=63235001&amp;id=283605519" title="iTunes Store">The Enchantress of Numbers</a>&#8220;. The episode of the great podcast &#8220;<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=283605519&amp;subMediaType=Audio" title="iTunes Store">Stuff you missed in history class</a>&#8220;.</li>
<li><a href="http://www.computerhistory.org/babbage/" title="The Babbage Engine | Computer History Museum">The difference engine</a>; A site dedicated to the work of Charles Babbage.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/esJS_cLx8C0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/ada-we-salute-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/ada-we-salute-you/</feedburner:origLink></item>
		<item>
		<title>AS3: Getting things done</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/0DohEfc9Gzk/</link>
		<comments>http://ria.creuna.com/2009/12/as3-getting-things-done/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 22:32:38 +0000</pubDate>
		<dc:creator>Andreas Rønning</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[duct tape]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[wall of text]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=530</guid>
		<description><![CDATA[I had a serious epiphany with OOP, when i was first learning it, where i realized that the real power of object oriented programming is the ability to build your own language dialect. No longer are you forced to use abstract constructs to make up your application. When i start a project, i throw down [...]]]></description>
			<content:encoded><![CDATA[<p>I had a serious epiphany with OOP, when i was first learning it, where i realized that the real power of object oriented programming is the ability to build your own language dialect. No longer are you forced to use abstract constructs to make up your application. When i start a project, i throw down the idea as <em>physically relatable </em>as possible on paper, and the next step is to do the same in stub classes in the project. This translates to <a href="http://www.boxesandarrows.com/">boxes and arrows</a> first, and then classes with names like Image and UserInputField. There is obviously already a Bitmap class and a TextField with an input type, but when i work, to keep myself in check and not lose track of the process, it helps me <em>mentally </em>to think of a specific input-field type rather than an input-field <em>variant </em>of another type. Long story short, this boils down to taking the tools i have available and labeling them for what use i have intended, both practically and mentally.</p>
<p>This ability to &#8220;bend the dictionary&#8221; is the #1 reason i am in love with programming, and probably why i can stomach doing it for a living at all. Design patterns are Good Things, but <a href="http://www.samuelfolkes.com/2009/09/of-design-patterns-and-patternitis/">overuse</a> and attitudes bordering on <em>religion</em> take this flexibility and bashes it with rocks until you&#8217;re back to square one;  Speaking another people&#8217;s language.</p>
<p><span id="more-530"></span>There has been a lot of discussion in the Flash community recently about fundamental choices Adobe have made when developing ActionScript 3 and the Flash platform. <a href="http://blog.joa-ebert.com/2009/09/01/first-results-of-taas/">Joa Ebert</a> has essentially torn the Flash compiler a new one over its lack of efficient compile-time optimizations, and <a href="http://robertpenner.com/flashblog/">Robert Penner</a> has been advocating a change in how Flash handles events, driving him to create his own alternative to the native event model, dubbed <a href="http://github.com/robertpenner/as3-signals">Signals</a>.</p>
<p>The compound effect of these two figureheads of the Flash community openly questioning Adobe&#8217;s wisdom has had a wonderful effect; Adobe have become noticeably better at responding to the community in recent years, but the questions raised by Penner and Ebert dig deep. When these guys ask what&#8217;s going on, their followers start asking the same questions. Twitter has been buzzing with this new found skepticism of the Flash platform and the design of the ActionScript language It&#8217;s forcing Adobe to question themselves. Only good things can come from that, and Adobe commentary at this year&#8217;s Flash on the beach indicate that the arguments have not gone unheard.</p>
<p>I am, however, worried that all this discussion of development fundamentals is taking the focus somewhat off the ball within the community. The vibe I&#8217;m getting is that getting the ball in the net isn&#8217;t as important as the flair with which you do it. I didn&#8217;t get any such vibe during the AS1/2 days, where the end product on display was what was being judged. Now, developers may feel like they are not doing a good job unless they are doing so while executing triple backflips.</p>
<p>My favorite boogieman example today is the notion that listening to enter-frame is bad because it generates a new event object on every frame update. As we &#8220;all know&#8221;, generating objects is the slowest thing you can do in Flash. This is, to me, a sign of a complete lack of focus. This is developers looking for a problem in the wrong place. A particular tweet i read went along the lines of &#8220;With all this talk about Events and enter-frames, i don&#8217;t know what to program anymore&#8221;. What a nightmare! To have your fundamental technique be thrown into question; It&#8217;s almost as though you are LAZY if you don&#8217;t change your way of thinking! This is not the good kind of skepticism. This is the kind that destroys productivity.</p>
<p>To attack this example in particular, the notion that enter-frame is slow is a reflective question; Perhaps you shouldn&#8217;t be relying on dozens of enter-frame events? Enter-frame events are used for real-time applications, and a <a href="http://en.wikipedia.org/wiki/Game_programming#The_game_loop">game loop model</a> and a <a href="http://en.wikipedia.org/wiki/Has-a">has-a relationship</a> gets around this quickly and elegantly with only one enter-frame in a single spot, as they have in game development for ages. A single enter-frame dispatch is enough to drive your entire application. That <em>a single object creation 60 times a second</em> is somehow a noticeable impediment to performance is flat out absurd.</p>
<p>To say that differently, you can safely ignore this whole discussion and get on with your work. The community is *riddled* with examples like this, from the broadest strokes (what design pattern to use, and if you don&#8217;t use design pattern X you are failing at life), to the most granular details (use &#8211;i, because i&#8211; is slower). When all you want to do is create something amazing, why should you have to wade through this minefield of needless exposition? I&#8217;ve seen the most fundamental advertising campaign sites with little more than a few video players and some transitions built in overwrought MVC-a-likes. It&#8217;s absolutely absurd!</p>
<p>This is something that has bugged me for a while, i felt like i need to get this out, and I&#8217;m hoping for some discussion. All this granular dissection of the most fundamental building blocks of our application is, in 99% of cases, a case of premature optimization and a complete waste of time. Our goal should be to develop quickly, efficiently and create good experiences for our users, not over-engineer.</p>
<p>I strongly urge developers to not let the multitude of senior developer prophets out there confuse you and take your focus off what actually teaches you real world lessons; getting the job done. I&#8217;m as guilty as anyone of this, and I&#8217;m struggling with it on a day by day basis. A recent example is an origami folding engine i spent 2 days over-engineering to cope with any and all possibilities, and Anders just sits down and does exactly what the job requires and delivers on time.</p>
<p>I hope this doesn&#8217;t read as some sort of attack on the science of programming and the brilliant people out there sciencing it up, but I&#8217;m starting to feel like we need <a href="http://www.joelonsoftware.com/items/2009/09/23.html">more duct tape, scissors and cardboard</a>.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/0DohEfc9Gzk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/as3-getting-things-done/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/as3-getting-things-done/</feedburner:origLink></item>
		<item>
		<title>Human-style URL recognition</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/S7WCoYKlx7M/</link>
		<comments>http://ria.creuna.com/2009/12/human-style-url-recognition/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 09:05:01 +0000</pubDate>
		<dc:creator>Martin Jacobsen</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[URLs]]></category>
		<category><![CDATA[validating]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/2009/12/human-style-url-recognition/</guid>
		<description><![CDATA[One of my pet peeves is that most regular expressions matching URLs fall somewhat short of what I expect. This pattern from John Gruber is so far the best I&#8217;ve found but, like virtually every other implementation, it doesn&#8217;t match URLs without protocol. Nobody expects to have to include &#8220;www&#8221; in a URL for it [...]]]></description>
			<content:encoded><![CDATA[<p>One of my pet peeves is that most <a href="http://en.wikipedia.org/wiki/Regular_expression" title="Regular expression - Wikipedia, the free encyclopedia">regular expressions</a> matching URLs fall somewhat short of what I expect. <a href="http://daringfireball.net/2009/11/liberal_regex_for_matching_urls">This pattern</a> from John Gruber is so far the best I&#8217;ve found but, like virtually every other implementation, it doesn&#8217;t match URLs <em>without protocol</em>. Nobody expects to have to include &#8220;www&#8221; in a URL for it to work these days, and in daily conversations it&#8217;s rare to enunciate &#8220;aitch-tee-tee-pee-colon-slash-slash&#8221; when you refer to some website. So why is it so hard to match URLs without using these strings as crutches?</p>
<p><img src="http://ria.creuna.com/wp-content/uploads/2009/12/fail_pattern.png" alt="Fail Pattern" height="236" width="480"><br />
<span id="more-447"></span><br />
To <strong>people</strong>, (or at least to people with some computer competence) it&#8217;s pretty easy to see the difference between a seemingly valid URL and an invalid one. To a computer it&#8217;s a lot harder than you&#8217;d might think if you want it to be both flexible and accurate at the same time.</p>
<p>To clarify; I want to match any of the following URLS,</p>
<ul>
<li><em class="urlreg">http://www.domain.com</em></li>
<li><em class="urlreg">www.domain.com</em></li>
<li><em class="urlreg">domain.com</em></li>
<li><em class="urlreg">subdomain.domain.com</em></li>
<li><em class="urlreg">subdomain.domain.com/some/path?to&#038;stuff</em></li>
<li><em class="urlreg">www.domain.com/</em></li>
<li><em class="urlreg">ftp://martin@domain.com:8080</em></li>
</ul>
<p>Naturally, I do not want to match false positives such as </p>
<ul>
<li><em class="urlreg">http@\/\:www.domain.combo</em></li>
<li><em class="urlreg">www.breakfast.com-org</em></li>
<li><em class="urlreg">bad.punctuation</em></li>
<li><em class="urlreg">http://.com</em></li>
</ul>
<p>This has turned out to be a lot more difficult than I thought; and not only because the ActionScript implementation of RegExp is, in my opinion, flaky as hell, but because I found it hard to explain in rules that a computer understands, the human intuition that tells us &#8220;google dot com&#8221; is a good URL while &#8220;burger dot ham&#8221; isn&#8217;t. </p>
<p>I made an honest attempt at resolving this problem with the <a href="http://ctrloptcmd.com/archives/587/actionscript-3-url-validator-class/">URLValidator class</a> back in february. The class performs pretty well at validating and finding URLs. However it works by doing some nasty jumping through various string-parsing hoops, and I&#8217;m currently rewriting it to be a tad more legible and efficient. I&#8217;ll publish the code when it&#8217;s done, but I thought I&#8217;d share some of the lessons and frustrations I&#8217;ve had at this point.</p>
<p><strong>Warning! This stuff is pretty geeky. No eye candy experiments here.</strong></p>
<p><!--more--></p>
<h2>The components of a valid URL</h2>
<p>So let&#8217;s have a look at what can, should, or may be found in a valid URL. I&#8217;ve made this handy chart as an intro (click for big version):</p>
<p><a class="thickbox" href="http://ria.creuna.com/wp-content/uploads/2009/12/urlmatching_rules_21.png" title="Urlmatching Rules" height="768" width="1024"><img src="http://ria.creuna.com/wp-content/uploads/2009/12/urlmatching_rules_thumb.png" alt="Urlmatching Rules Thumb" height="432" width="576"></a></p>
<p>There are several points to be considered here:</p>
<ul>
<li><strong>The protocol:</strong> Just matching literally <em class="urlreg">http://</em> is at best naíve. There are multiple other protocols to consider. These days there seems to be even more of them as apps invent their own protocol prefixes. iTunes podcast prefixes start with <em class="urlreg">itpc://</em>, Spotify links have <em class="urlreg">spotify://</em> and you can even send commands to <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">TextMate</a> with <em class="urlreg">txmt://</em>. Perhaps you don&#8217;t want to support all these crazy protocols, but you need to <strong>at least</strong> be able to accept ( http | https | ftp ). Matching the protocol is also extremely handy to use as a word boundary. That is; Search for something that looks like a protocol and that&#8217;s where we&#8217;ll start our matching.<br /> Seeing as I want the protocol to be optional there&#8217;s no such luck here though. In order to handle the protocol if it <strong>is</strong> present you might do something like this:
<ul>
<li>Does the string contain <em class="urlreg">://</em>?</li>
<li>If yes, check for valid characters before the match and proceed to validate domain after the match.</li>
<li>If no; proceed to validate domain from the start of the string.</li>
</ul>
</li>
<li>The URL may contain the <em class="urlreg">www.</em> prefix, or it may not. It might include any number of subdomains or none at all. <em class="urlreg">http://a.long.subdomain.bin-debug.net/</em> is a valid URL, so searching for <em class="urlreg">www.</em> is silly as it would exclude any other valid subdomain. Yes <em class="urlreg">www.</em> is certainly <em>indicative</em> of a URL, but in my opinion it should be treated as any other subdomain.</li>
<li><strong>Matching domain + Top Level Domain:</strong> <br />Optional protocols, haphazard subdomains&#8230; Is there anything concrete left to match?<br />
	Yes. Yes there is. Every valid URL will somewhere in it contain the following structure:<br /> <br />
<em class="urlreg">[domain-name][.][TLD][(end-of-string | / | ? | : )]</em> where</p>
<ul>
<li><em class="urlreg">[domain-name]</em> is a string of 1 or more characters in the range a-z, 0-9 or &#8220;-&#8221; and may not start with &#8220;-&#8221;</li>
<li><em class="urlreg">[.]</em> is literally a period and absolutely nothing else.</li>
<li><em class="urlreg">[TLD]</em> is one of the 267 legal <a href="http://en.wikipedia.org/wiki/Top-level_domain" title="Top-level domain - Wikipedia, the free encyclopedia">Top Level Domains</a>.</li>
<li><em class="urlreg">[(end-of-string | / | ? | : )]</em> is either the &#8220;/&#8221; character, the &#8220;?&#8221; character, the &#8220;:&#8221; character (usually followed by numbers) or nothing at all. That is to say: If the next character is a space, the url string is at its end.</li>
</ul>
</li>
<li>After the domain-dot-TLD-/? sequence you&#8217;ll find all sorts of stuff. These are the legal characters you might run into: <em class="urlreg">/~*?.,;:-%=_$s&#038;&#8217;&#8221;@!)(][+</em>. To be honest; If I manage to confirm a valid URL up to the character following the TLD I just run a match on those characters until I find a white space although there are probably some combinations of these legal characters that are not valid.</li>
</ul>
<p>Ok. That's something to hang on to. Knowing that no white space is allowed in URLs, and that we can't rely on the handy protocol to find the beginning of the potential URL we instead fixate on this structure which is guaranteed to be present in a valid URL (disregarding IP-addresses for the moment.) Our method of matching should then, from a mile high view, be:</p>
<ul>
<li>Is there a valid domain-dot-tld-endcharacter structure present in the string?</li>
<li>If yes, work backwards to find the legal structures of subdomains or protocols or end-of-string.</li>
<li>Work forward to find end-of-string or illegal character.</li>
</ul>
<h2>Validating the Domain</h2>
<p>Having decided to start with the root domain for your matching this is what you're looking for:<br />
</p>
<h3><em class="urlreg">http://www.all.kinds.of.crap.<strong style="color:red;">domain-name.com/</strong>even/more?crap#here</em></h3>
<p>&nbsp;<br />
If you match this unbroken sequence (remember <em>[domain-name][.][TLD][end-of-string or ( ? | / | : )]</em>) you have a starting point. Now you need to see if whatever comes <em>before</em> or <em>after</em> your match is valid.</p>
<p>The end of the TLD string is very important. Consider this; <em class="urlreg">http://sub.combo.co/</em>. In this case we find the &#8220;.com&#8221; first, but it isn&#8217;t followed by a legal end character. Moving on we see that .co however is, and identify the TLD correctly.</p>
<h2>Verifying the TLD</h2>
<p>At this point regular expressions won&#8217;t be able to help you any more. At least not efficiently. The Top Level Domain list just isn&#8217;t really mappable in patterns. Example. <em class="urlreg">.cc</em> <em class="urlreg">.cd</em> and <em class="urlreg">.cf</em> are all valid TLDs, but <em class="urlreg">.ce</em> is not. If you don&#8217;t really care whether the TLD is actually valid rather than just structurally sound you would typically match a string of 2-6 characters in the a-z range and leave it at that. <br />
If you <strong>do</strong> want to make sure that <em class="urlreg">domain.fuck</em> or <em class="urlreg">domain.yo</em> aren&#8217;t regarded as positives and that the valid country codes <em class="urlreg">.no</em> and <em class="urlreg">.ly</em> are, there&#8217;s nothing for it but to use the actual list and loop through it.</p>
<p>For your convenience here is a <a class="thickbox" href="#TB_inline?height=100&#038;width=580&#038;inlineId=hiddenModalContent&#038;modal=false">code example</a> of a Vector.&lt;String&gt; containing all TLDs and sorted by length.</p>
<div style="visibility:hidden; height:0px;" id="hiddenModalContent">
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var domainList = new Vector.&lt;String&gt;();<br />
&nbsp; domainList.push (&quot;.ac&quot;,&quot;.ad&quot;,&quot;.ae&quot;,&quot;.aero&quot;,&quot;.af&quot;,&quot;.ag&quot;,&quot;.ai&quot;,&quot;.al&quot;,<br />
&nbsp; &quot;.am&quot;,&quot;.an&quot;,&quot;.ao&quot;,&quot;.aq&quot;,&quot;.ar&quot;,&quot;.arpa&quot;,&quot;.as&quot;,&quot;.asia&quot;,&quot;.at&quot;,&quot;.au&quot;,<br />
&nbsp; &quot;.aw&quot;,&quot;.ax&quot;,&quot;.az&quot;,&quot;.ba&quot;,&quot;.bb&quot;,&quot;.bd&quot;,&quot;.be&quot;,&quot;.bf&quot;,&quot;.bg&quot;,&quot;.bh&quot;,&quot;.bi&quot;,<br />
&nbsp; &quot;.biz&quot;,&quot;.bj&quot;,&quot;.bm&quot;,&quot;.bn&quot;,&quot;.bo&quot;,&quot;.br&quot;,&quot;.bs&quot;,&quot;.bt&quot;,&quot;.bv&quot;,&quot;.bw&quot;,&quot;.by&quot;,<br />
&nbsp; &quot;.bz&quot;,&quot;.ca&quot;,&quot;.cat&quot;,&quot;.cc&quot;,&quot;.cd&quot;,&quot;.cf&quot;,&quot;.cg&quot;,&quot;.ch&quot;,&quot;.ci&quot;,&quot;.ck&quot;,&quot;.cl&quot;,<br />
&nbsp; &quot;.cm&quot;,&quot;.cn&quot;,&quot;.co&quot;,&quot;.com&quot;,&quot;.coop&quot;,&quot;.cr&quot;,&quot;.cu&quot;,&quot;.cv&quot;,&quot;.cx&quot;,&quot;.cy&quot;,&quot;.cz&quot;,<br />
&nbsp; &quot;.de&quot;,&quot;.dj&quot;,&quot;.dk&quot;,&quot;.dm&quot;,&quot;.do&quot;,&quot;.dz&quot;,&quot;.ec&quot;,&quot;.edu&quot;,&quot;.ee&quot;,&quot;.eg&quot;,&quot;.er&quot;,<br />
&nbsp; &quot;.es&quot;,&quot;.et&quot;,&quot;.eu&quot;,&quot;.fi&quot;,&quot;.fj&quot;,&quot;.fk&quot;,&quot;.fm&quot;,&quot;.fo&quot;,&quot;.fr&quot;,&quot;.ga&quot;,&quot;.gb&quot;,<br />
&nbsp; &quot;.gd&quot;,&quot;.ge&quot;,&quot;.gf&quot;,&quot;.gg&quot;,&quot;.gh&quot;,&quot;.gi&quot;,&quot;.gl&quot;,&quot;.gm&quot;,&quot;.gn&quot;,&quot;.gov&quot;,&quot;.gp&quot;,<br />
&nbsp; &quot;.gq&quot;,&quot;.gr&quot;,&quot;.gs&quot;,&quot;.gt&quot;,&quot;.gu&quot;,&quot;.gw&quot;,&quot;.gy&quot;,&quot;.hk&quot;,&quot;.hm&quot;,&quot;.hn&quot;,&quot;.hr&quot;,<br />
&nbsp; &quot;.ht&quot;,&quot;.hu&quot;,&quot;.id&quot;,&quot;.ie&quot;,&quot;.il&quot;,&quot;.im&quot;,&quot;.in&quot;,&quot;.info&quot;,&quot;.int&quot;,&quot;.io&quot;,&quot;.iq&quot;,<br />
&nbsp; &quot;.ir&quot;,&quot;.is&quot;,&quot;.it&quot;,&quot;.je&quot;,&quot;.jm&quot;,&quot;.jo&quot;,&quot;.jobs&quot;,&quot;.jp&quot;,&quot;.ke&quot;,&quot;.kg&quot;,&quot;.kh&quot;,<br />
&nbsp; &quot;.ki&quot;,&quot;.km&quot;,&quot;.kn&quot;,&quot;.kp&quot;,&quot;.kr&quot;,&quot;.kw&quot;,&quot;.ky&quot;,&quot;.kz&quot;,&quot;.la&quot;,&quot;.lb&quot;,&quot;.lc&quot;,<br />
&nbsp; &quot;.li&quot;,&quot;.lk&quot;,&quot;.lr&quot;,&quot;.ls&quot;,&quot;.lt&quot;,&quot;.lu&quot;,&quot;.lv&quot;,&quot;.ly&quot;,&quot;.ma&quot;,&quot;.mc&quot;,&quot;.md&quot;,<br />
&nbsp; &quot;.me&quot;,&quot;.mg&quot;,&quot;.mh&quot;,&quot;.mil&quot;,&quot;.mk&quot;,&quot;.ml&quot;,&quot;.mm&quot;,&quot;.mn&quot;,&quot;.mo&quot;,&quot;.mobi&quot;,&quot;.mp&quot;,<br />
&nbsp; &quot;.mq&quot;,&quot;.mr&quot;,&quot;.ms&quot;,&quot;.mt&quot;,&quot;.mu&quot;,&quot;.museum&quot;,&quot;.mv&quot;,&quot;.mw&quot;,&quot;.mx&quot;,&quot;.my&quot;,&quot;.mz&quot;,<br />
&nbsp; &quot;.na&quot;,&quot;.name&quot;,&quot;.nc&quot;,&quot;.net&quot;,&quot;.nf&quot;,&quot;.ng&quot;,&quot;.ni&quot;,&quot;.nl&quot;,&quot;.no&quot;,&quot;.np&quot;,&quot;.nr&quot;,<br />
&nbsp; &quot;.nu&quot;,&quot;.nz&quot;,&quot;.om&quot;,&quot;.org&quot;,&quot;.pa&quot;,&quot;.pe&quot;,&quot;.pf&quot;,&quot;.pg&quot;,&quot;.ph&quot;,&quot;.pk&quot;,&quot;.pl&quot;,<br />
&nbsp; &quot;.pm&quot;,&quot;.pn&quot;,&quot;.pr&quot;,&quot;.pro&quot;,&quot;.ps&quot;,&quot;.pt&quot;,&quot;.pw&quot;,&quot;.py&quot;,&quot;.qa&quot;,&quot;.re&quot;,&quot;.ro&quot;,<br />
&nbsp; &quot;.rs&quot;,&quot;.ru&quot;,&quot;.rw&quot;,&quot;.sa&quot;,&quot;.sb&quot;,&quot;.sc&quot;,&quot;.sd&quot;,&quot;.se&quot;,&quot;.sg&quot;,&quot;.sh&quot;,&quot;.si&quot;,<br />
&nbsp; &quot;.sj&quot;,&quot;.sk&quot;,&quot;.sl&quot;,&quot;.sm&quot;,&quot;.sn&quot;,&quot;.so&quot;,&quot;.sr&quot;,&quot;.st&quot;,&quot;.su&quot;,&quot;.sv&quot;,&quot;.sy&quot;,<br />
&nbsp; &quot;.sz&quot;,&quot;.tc&quot;,&quot;.td&quot;,&quot;.tel&quot;,&quot;.tf&quot;,&quot;.tg&quot;,&quot;.th&quot;,&quot;.tj&quot;,&quot;.tk&quot;,&quot;.tl&quot;,&quot;.tm&quot;,<br />
&nbsp; &quot;.tn&quot;,&quot;.to&quot;,&quot;.tp&quot;,&quot;.tr&quot;,&quot;.travel&quot;,&quot;.tt&quot;,&quot;.tv&quot;,&quot;.tw&quot;,&quot;.tz&quot;,&quot;.ua&quot;,<br />
&nbsp; &quot;.ug&quot;,&quot;.uk&quot;,&quot;.us&quot;,&quot;.uy&quot;,&quot;.uz&quot;,&quot;.va&quot;,&quot;.vc&quot;,&quot;.ve&quot;,&quot;.vg&quot;,&quot;.vi&quot;,&quot;.vn&quot;,<br />
&nbsp; &quot;.vu&quot;,&quot;.wf&quot;,&quot;.ws&quot;,&quot;.ye&quot;,&quot;.yt&quot;,&quot;.yu&quot;,&quot;.za&quot;,&quot;.zm&quot;,&quot;.zw&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
domainList.sort(strLenSort);<br />
function strLenSort(x:String,y:String) : Number {<br />
&nbsp; &nbsp; if (x.length &gt; y.length){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; }<br />
}</div></div>
</div>
<p>Stop. Exhale.</p>
<h2>The rest of the string</h2>
<p>Once you&#8217;ve identified the aforementioned structure you need to look forward and backward in the string. When looking forward you&#8217;re typically looking for either an illegal character or whitespace and assuming the end of the URL at the matching point.<br />
When you look backward there are several different options you need to match. You will be looking for either:</p>
<ul>
<li>A subdomain. These are groups of characters in the a-z,0-9 range or &#8220;-&#8221;, just like domain names. They are separated by dots and there doesn&#8217;t seem to be any limit to how many you can make, but usually you won&#8217;t find more than one of these.</li>
<li>A protocol. Protocols seem to follow the same convention as domain names, except for a couple of characteristics.
<ul>
<li>They are followed by &#8220;://&#8221; rather than &#8220;.&#8221;</li>
<li>They&#8217;ll always be found at the start of the URL string, if present.</li>
<li>To my knowledge you can only have a single protocol in a URL.</li>
</ul>
</li>
<li>A user prefix. These are the <em class="urlreg">ftp://martin@domain.com</em> or <em class="urlreg">https://user:password@domain.com</em> variants.
</ul>
<p>Why can&#8217;t it ever be easy&#8230;<br />
So a pattern to match whatever comes before the domain-dot-TLD-/? sequence would look something like this:</p>
<ul>
<li>Start from the beginning of the validated domain.</li>
<li>Is there anything at all (except white space) before the validated domain?</li>
<li>If yes; Does it contain &#8220;://&#8221;, and only once?</li>
<li>If yes; is &#8220;://&#8221; preceded by a string of characters in the range (&#8220;a-z&#8221;, &#8220;0-9&#8243;, &#8220;-&#8221;)?</li>
<li>If yes; Start from the end of &#8220;://&#8221;. Is there anything before the validated domain?</li>
<li>If yes; Does it consist of valid domain strings separated by dots (&#8220;a-z&#8221; &#8220;0-9&#8243; &#8220;-&#8221;) and alternatively either or both of &#8220;@&#8221; and &#8220;:&#8221;?</li>
</ul>
<p>And so forth.</p>
<h2>But wait!</h2>
<p>So you&#8217;ve finally got it working perfectly. Your pattern gets matches on all the valid examples at the top of this post, and rejects all the false positives. Pat yourself on the back, and then consider this.</p>
<p>What about characters that invalidate your URL, but frequently occur in the wild? Or what about the characters that are allowed in the URL, but almost certainly were meant as punctuation.<br />
For example:</p>
<ul>
<li><em class="urlreg">=&#8221;http://</em> isn&#8217;t valid as the beginning of a protocol, and <em class="urlreg">.com&#8221;</em> isn&#8217;t a valid TLD but you will probably run into this: <em class="urlreg">&lt;a href=&#8221;http://domain.com&#8221;&gt;</em></li>
<li>While &#8220;)&#8221;, &#8220;,&#8221; and &#8220;.&#8221; are legal characters in a URL, it probably wasn&#8217;t meant to be part of the link in this example: <br />&#8220;W00t! Listening to TWIT (http.twit.tv).&#8221;<br /> However, in this case:<br />
		&#8220;Have you guys heard of this? http://en.wikipedia.org/wiki/WWII_(disambiguation)  &#8220;<br />
		It&#8217;s actually meant to be included.</li>
</ul>
<p>As is plain to see it&#8217;s not easy validating URLs with precision once you remove the protocols. It seems like it should be, but it&#8217;s not. I never got it to work, but just the fact that <a href="http://internet.ls-la.net/folklore/url-regexpr.html" title="Best of Internet: The complete regular expression for URLs">this pattern</a> exists tells you something about just how frustrating an experience it is. The usual compromise is to decide (perhaps sensibly) that it&#8217;s not worth the effort to try and catch unlikely cases such as <em class="urlreg">http://subdo://main.com</em> since the chance of it occurring in the wild are slim. Me, I obsess about shit like this.</p>
<p>If any of you have some insights that I may have missed, be sure to leave a comment. I know that this text excludes both local characters (æøå) and IP-addresses, which is something I may or may not rectify.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/S7WCoYKlx7M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/12/human-style-url-recognition/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/12/human-style-url-recognition/</feedburner:origLink></item>
		<item>
		<title>Solving clickTAG in Flash9+</title>
		<link>http://feedproxy.google.com/~r/riacreuna/~3/vMDpEdqBVvY/</link>
		<comments>http://ria.creuna.com/2009/11/solving-clicktag-in-flash9/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:11:44 +0000</pubDate>
		<dc:creator>Andreas Rønning</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[banners]]></category>
		<category><![CDATA[clicktag]]></category>

		<guid isPermaLink="false">http://ria.creuna.com/?p=413</guid>
		<description><![CDATA[(This is a slightly more pc rewrite of an article from my personal blog. I repost it here in the hopes that it&#8217;ll reach a more appropriate audience) I had a revelation today, and it makes me furious to the point of wall-climbing. I&#8217;m not going to mention names, but you know all that talk [...]]]></description>
			<content:encoded><![CDATA[<p><em>(This is a slightly more pc rewrite of an article from my personal blog. I repost it here in the hopes that it&#8217;ll reach a more appropriate audience)</em></p>
<p>I had a revelation today, and it makes me furious to the point of wall-climbing. I&#8217;m not going to mention names, but you know all that talk about how clickTAG doesn&#8217;t work in Flash 9+? Complete sham. First of all, since ad publishers are uniformly incapable of explaining the perceived &#8220;intricacies&#8221; of their magical clickTAG system outside of &#8220;Please copy this simple AS2 code into your application&#8221;, i&#8217;ll go through what clickTAG actually <em>is</em>, how i implement it, and a hilarious case of misinformation and unprofessional conduct indicative of certain elements of this industry.<br />
<span id="more-413"></span></p>
<p>Ready to know the <em>AWESOME POWER</em> of clickTAG? Drumroll. clickTAG is a flashvar containing the url to open. High tech! This URL points to a forwarding and tracking service, but beyond it being a valid URL it isn&#8217;t your problem anymore. It might as well be http://www.google.com for all you should have to care. The important thing to take with you here is that no matter how badly the publisher wants you to think there is MAGIC involved that <em>you don&#8217;t understand</em>, the tech is caveman simple, and the problem in 9/10 cases lies with the agency.</p>
<p>So how do we get this flashvar? In AS2, where near-every class was dynamic, flashvars were simply appended as properties to the root object. For instance, given the flashvar &#8220;foobar&#8221;, you could access it with _root.foo, or if working on root level of the timeline, simply refer directly to foobar. For instance, here&#8217;s a straight copy from a clickTAG guide:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">on</span> <span style="color: #66cc66;">&#40;</span>release<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #0066CC;">getURL</span><span style="color: #66cc66;">&#40;</span>clickTAG, <span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>This is, hilariously, the ONLY available documentation if you Google for official info, and it neglects to explain what would happen if you were to actually paste this code into a nested button or MovieClip.<br />
This is where the clickTAG problem begins. It simply isn&#8217;t specific enough. For instance, in the previous example, the variable name is clickTAG. This is however not <i>really</i> a standard. It might be ClickTag, it might be clickTAG, it might be clickTag, or any combination of cases. For AS3, which is case sensitive, this is a no-go. You might have a perfectly workable clickTag implementation only to have the publisher reject it as non-specifically &#8220;wrong&#8221;, simply because their cases are nonstandard.</p>
<p>Our first problem then, is how do you get the right clickTAG variable, and from where. The stage and root objects of any relevant on-stage DisplayObject (Sprite, MovieClip) hold references to a LoaderInfo object, which in turn has a dynamic &#8220;parameters&#8221; object which is populated by the embed script. Thus, to get at &#8220;clickTAG&#8221;, you&#8217;d typically use something like this.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span><br />
navigateToURL<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">clickTAG</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>With that out of the way, how can we make our solution case insensitive? The natural solution, i feel, is to for-in through the parameters object, toLowerCase each variable name and get any matching results, as such:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">String</span> <span style="color: #b1b100;">in</span> li.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;clicktag&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #0066CC;">url</span> = li.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>From there on the rest becomes absolutely trivial.</p>
<ol>
<li> MouseEvent objects have a target property pointing to whatever the user clicked</li>
<li>Whatever the user clicked is on stage</li>
<li>The stage has a loaderInfo property</li>
<li>And there we have our variables!</li>
</ol>
<p>The result is a framework for a method we can call from wherever that will always know where the stage is, and will always know where to find the variables, and will always be case insensitive. In our  implementation, this results in the following:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handleClick<span style="color: #66cc66;">&#40;</span>mouseEvent:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> interactiveObject:InteractiveObject = mouseEvent.<span style="color: #0066CC;">target</span> as InteractiveObject;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> li:LoaderInfo = LoaderInfo<span style="color: #66cc66;">&#40;</span>interactiveObject.<span style="color: #006600;">root</span>.<span style="color: #006600;">loaderInfo</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">url</span>:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">String</span> <span style="color: #b1b100;">in</span> li.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;clicktag&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">url</span> = li.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ExternalInterface.<span style="color: #006600;">available</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'window.open'</span>,<span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; navigateToURL<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>ExternalInterface.<span style="color: #006600;">available</span><span style="color: #66cc66;">&#41;</span> ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'console.log'</span>, <span style="color: #ff0000;">&quot;ClickTAG: Couldn't find a valid clicktag variable&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
myButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>,handleClick<span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>Using ExternalInterface</strong><br />
There is some debate, apparently, as to whether navigateToURL with a _blank target is &#8220;reliable&#8221;. It appears navigateToURL from older browsers may be misinterpreted as an automated popup and thus blocked regardless of user interaction. I have personally <em>never encountered this issue</em>, from testing with a multitude of browsers, so i&#8217;m taking this issue with a huge pinch of salt.<br />
Regardless, the accepted &#8220;fix&#8221; to this problem is to circumvent navigateToURL altogether and instead call the Javascript window.open through ExternalInterface. I&#8217;m not sold on this, but i&#8217;ve implemented it anyway primarily just in case.</p>
<p><strong>A tale of escapades</strong><br />
Today i had a long, winding, pointless argument with a publisher. We supplied a set of AS3 banners using the above method, which were rejected. Out of professional curiosity, i see it as my responsibility to figure out where this process fails, and if there is something i can do about it. Immediately i get the standard company line, copied straight out of the aforementioned clickTAG guide; An AS2 code example. I inform them in return that our implemented code in effect follows this standard to a tee, and that our application is Flash 9 only, and thus incompatible with their code snippet. We do not deliver content in outdated technology, so the problem stands; How do we make this work? We both work for the same client; isn&#8217;t it in our best interest to keep them happy?<br />
The response is a rewrite of the same nonsense, with no further details given; This is obviously a person on the other end with little idea what she&#8217;s selling or how it works. </p>
<p>As this pointless exercise in &#8220;i&#8217;m right because i say so&#8221; goes on, i start doing more research; What possible method could they be using to validate these swfs? They&#8217;re obviously not implementing them in a standard way, because the standard way is toilet training simple, and we are supplying several sets of embedded examples that show clickTAG operating as expected, so what could they be doing? We come across <a href="http://www.inma.no/fag-og-verktoey/verktoey-/inma-testcenter-for-clicktag">INMA&#8217;s SWF clickTAG validator</a>, which purports to judge whether a SWF has clickTAG properly implemented. Uploading our banners immediatly fails, but with the strange error message that clicktag is written as &#8220;ClickTag&#8221;, not &#8220;clickTAG&#8221;.  Puzzling, since we don&#8217;t actually have any ClickTag strings in our banners at all. Cristobal points out that my ClickTag utility has that very same camelcase name. Hmm!</p>
<p>So we make a new SWF, drop in the following.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;clickTAG&quot;</span>;</div></div>
<p>What do you know? This empty trojan SWF validates perfectly. After rapid-fire facepalms, we change the classname to clickTAG and retest our banners; They now validate perfectly. </p>
<p>In the meantime, the discussion with the publisher has rolled on; They have &#8220;<em>tested the banners</em>&#8220;, with our ClickTag class, &#8220;<em>in 3 different systems and it doesn&#8217;t work</em>&#8220;. We send over new banners with the renamed class. Oh but now they &#8220;<em>work perfectly</em>&#8220;!</p>
<p><em><strong>Mind. Blowing. </strong></em></p>
<p>Publishers are lying to us because they know next to nothing about what they are selling. They force us to use ancient technology (five years now since Flash 8!) under the pretense of some magical system they operate, that they themselves don&#8217;t know well enough to diagnose, and they don&#8217;t have the courtesy to be honest about that.</p>
<p>Flash developers; You do not need to use Flash 8/AS2, no matter what they tell you. You don&#8217;t. Don&#8217;t let these dinosaurs drag us down. Their time has obviously passed.</p>
<img src="http://feeds.feedburner.com/~r/riacreuna/~4/vMDpEdqBVvY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ria.creuna.com/2009/11/solving-clicktag-in-flash9/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://ria.creuna.com/2009/11/solving-clicktag-in-flash9/</feedburner:origLink></item>
	</channel>
</rss>

