<?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>sevenson.com.au</title>
	<atom:link href="http://www.sevenson.com.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sevenson.com.au</link>
	<description>The online presence of Andrew Sevenson</description>
	<lastBuildDate>Sat, 19 May 2012 05:20:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Lynx Fastlife &#8211; Behind the Scenes &#8211; Part 2</title>
		<link>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-2/</link>
		<comments>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-2/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 10:30:54 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=953</guid>
		<description><![CDATA[In my previous post I explained how I generated the sequences used in the Lynx Fastlife app &#8211; which you can read about here. Now I&#8217;m gonna run through how I did the overlays and data insertion for the app &#8211; the part that I think is the really cool part. Content, tracking and data [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post I explained how I generated the sequences used in the Lynx Fastlife app &#8211; which you can read about <a href="http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/" title="Lynx Fastlife – Behind the Scenes – Part 1">here</a>. Now I&#8217;m gonna run through how I did the overlays and data insertion for the app &#8211; the part that I think is the really cool part.</p>
<p><span id="more-953"></span></p>
<h3 id="content">Content, tracking and data insertion</h3>
<p>The types of content came in three possible flavours &#8211; videos, stills and swf animations.  They were all slightly different, but shared a lot of common elements, so I created an abstract segment class to handle all the base elements.</p>
<p>This abstract class was set up in such a way that it would automatically load all of the resources you specified in the XML.  This allowed the me to load in the main resources for images, videos or swfs, as well as any audio tracks, tracking data, support elements, etc. The basic XML structure for a segment looked a bit like this:</p>
<p><code class="as">&lt;segment type="video" duration="10"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&gt;url_to_video&gt;/item&gt;<br />
		&lt;item id="audio"&gt;url_to_audio&gt;/item&gt;<br />
		&lt;item id="other"&gt;url_to_other_item&gt;/item&gt;<br />
	&lt;/resources&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<p>Basically, I could get it to preload anything I wanted. Once I had this set up, I simply extended it to suit each of the different types of segments, each of which I will go into now.</p>
<h4 id="video">Video Segments</h4>
<p>Video segment were the most interesting type of segment.  A plain video segment was simple in that it just had to be able to load and play the required file.  The fun part was the videos that had content dynamically overlaid.</p>
<p>To do an overlay took a number of steps.</p>
<p>Firstly, our video guru (JB) tracked the required areas in the video (and also gave them a clean up while he was at it).  This dumped out a massive txt file with all the co-ordinates for the tracking rectangle&#8217;s corners. I think he used an app called Mocha?.. not sure about the name.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/trackingToText.jpg" alt="Points are tracked in the videos and output as a text file" title="trackingToText" width="600" height="155" class="alignnone size-full wp-image-1000" /></p>
<p>Next we ran this text file through a python script (that Rob created) that reformatted it into an XML document that we could use in flash.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/pointToXML.jpg" alt="The text data for the points is converted into XML" title="pointToXML" width="600" height="155" class="alignnone size-full wp-image-999" /></p>
<p>Alrighty &#8211; now that we had it in a format that flash could understand, we could hook it up in the segment XML using a method similar to this:</p>
<p><code class="as">&lt;segment type="video" duration="10"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&gt;url_to_video&gt;/item&gt;<br />
		&lt;item id="audio"&gt;url_to_audio&gt;/item&gt;<br />
		&lt;item id="trackdata"&gt;url_to_overlay_data&gt;/item&gt;<br />
	&lt;/resources&gt;<br />
	&lt;overlays&gt;<br />
		&lt;item userdata="user" trackingdata="trackdata"/&gt;<br />
	&lt;/overlays&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<p>From the above XML you should be able to see that I had an &#8216;overlay&#8217; set of nodes that linked to a tracking XML file I loaded as a resource to this segment.</p>
<p>I wrote a class that would take in the XML, parse it into a Vector of Point objects (because it was faster that working with the pure XML), and then I would use the current time of the video over the video duration to create a percentage that I would use to figure out which set of points to use for the overlay.  I had to do it that way because video&#8217;s don&#8217;t have a frame property, so we had to kinda fudge it using percentages.</p>
<p>For the most part this worked well, but on some videos there was a slight jitter, so I set it up so that when the XML was parsed into Point objects, I would interpolate an extra Point data between each node so that it would smooth out the motions a bit.</p>
<p>Because the rectangle shapes were never perfectly square I had to use the drawTriangles() method to distort the BitmapData.  I wrote a small class to handle the actual drawing of the BitmapData where I could set any of the four corners of the rectangle (based on the Points we looked up) and the number of horizontal and vertical segments to use, and it would spit out all the data I needed to for a drawTriangles() call, including the vertices, indices and uvData info.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/drawTriangles.jpg" alt="Diagram showing the Draw Triangles layout" title="Draw Triangles" width="600" height="155" class="alignnone size-full wp-image-1001" /></p>
<p>So, that&#8217;s how we did the actual overlays, but because the images weren&#8217;t always the same for each video I had to come up with a way to process the images on a case by case situation.</p>
<p>For starters, I made it in so that in the XML you could specify what data should be used to generate the overlay BitmapData.  You could specify the user&#8217;s profile pic, the cropped pic, a random friend or a specific friend. </p>
<p>Then, to give myself some more control over how the images were displayed and help them blend in with the videos more, I added in some optional attributes that would adjust the actual BitmapData before it was displayed.</p>
<p>First I added in some basic width, height and rotation attributes to allow the images to be resized to a ratio that better suited the video overlay.  Then I hooked up Quasimondo&#8217;s <a href="http://www.quasimondo.com/colormatrix/ColorMatrix.as" title="ColorMatrix class">ColorMatrix</a> class  so that I could adjust the hue, brightness, etc. of the image at run time.</p>
<p>Adding in these properties made it really easy to adjust the overlay images so that they blended in with the videos and looked pretty damn seamless.  </p>
<p>Finally, not all of the video overlays were to use the profile pics of the different users &#8211; some of them required things like the users name or a custom design. To do this, I came up with a &#8216;preprocessor&#8217; approach that allowed me to do pretty much whatever I needed.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/processorFlow.jpg" alt="Work flow of pre-processors" title="processor Flow" width="600" height="155" class="alignnone size-full wp-image-1002" /></p>
<p>The way that the preprocessors worked was that I set up a interface that all processors would use.  They would take in the FacebookUser object that was based on whatever user data they were told to use, generate a new BitmapData and then return it to the overlay object.</p>
<p>To make the processors more re-usable, I made it so that the actual XML node was passed to the processor as well, so you could add in extra custom data for the processor to work with (A good example of this was all the newspaper headlines that used the same processor, but passed in different titles as extra data in the XML)</p>
<p>What you ended up with them was some XML that looked like this:</p>
<p><code class="as">&lt;segment type="video" duration="10"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&gt;url_to_video&gt;/item&gt;<br />
		&lt;item id="audio"&gt;url_to_audio&gt;/item&gt;<br />
		&lt;item id="trackdata"&gt;url_to_overlay_data&gt;/item&gt;<br />
		&lt;item id="processor"&gt;url_to_processor_data&gt;/item&gt;<br />
	&lt;/resources&gt;<br />
	&lt;overlays&gt;<br />
		&lt;item userdata="user" trackingdata="trackdata" processor="processor" width="100, height="150" brightness="-50"/&gt;<br />
	&lt;/overlays&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<p>This approach meant that we could basically generate any graphic or style we needed for any video overlay in the entire site &#8211; all with a pretty minimal fuss <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3 id="swf">SWF Segments</h3>
<p>The other semi-complex type of segments were customised SWF segments.</p>
<p>Instead of trying to overlay the data on a SWF, we found it better to actually insert the data into the actual SWF- that way, we could lay out any basic animations using place holder graphics, then simply replace them at run time.</p>
<p>The process for this was to set the SWF up so that it implements and interface.  Using this interface the app would pass in the data specified in the XML in a similar fashion to the way that the video overlays worked.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/SWFInsert.jpg" alt="Diagram showing how images go straight into SWFs" title="SWF Insert Process" width="482" height="155" class="alignnone size-full wp-image-1006" /></p>
<p>There was no real need for preprocessors with SWF objects because the SWFs could apply whatever effects they needed internally.  I did leave in the ability to do the usual effects like resizing and brightness though, just in case.</p>
<p><code class="as">&lt;segment type="swf" duration="2"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&gt;url_to_swf&gt;/item&gt;<br />
	&lt;/resources&gt;<br />
	&lt;overlays&gt;<br />
		&lt;item userdata="user" width="100" height="150" brightness="-50"&gt;<br />
	&lt;/overlays&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<h3 id="image">Image Segments</h3>
<p>The final type of segment used in the site was an Image segment.  These were the most basic type of segment in that all they did was load and display an image.  There was no need for any sort of data insertion with this type of segment so I was able to keep it very simple.</p>
<p><code class="as">&lt;segment type="image" duration="0.15"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&gt;url_to_image&gt;/item&gt;<br />
	&lt;/resources&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<p>The image was simply displayed on screen using a timer that ran for the amount of time that was specified in the duration.</p>
<h3 id="conclusion">Conclusion</h3>
<p>So, that is how the Lynx Fastlife website pretty much works. By combining the random story generation techniques described in <a href="http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/" title="Lynx Fastlife – Behind the Scenes – Part 1">part 1</a> of this post to create a story, and combining it with the techniques I described above, we were able to generate a pretty cool customised experience for the users that in theory should never be exactly the same twice.</p>
<p>I could never have finished this project on time or to the standard it was at without the help of all the guys at VJ &#8211; namely Erik, Rosy, Cookie, JB, Vincent, Michelle and Simon &#8211; it was a massive team effort to get it over the line and hopefully the whole campaign will be successful!</p>
<p>If you haven&#8217;t done so already, be sure to check it out at <a href="http://www.lynxfastlife.com.au" title="Lynx Fastlife" target="_blank">http://www.lynxfastlife.com.au</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-2/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lynx Fastlife &#8211; Behind the Scenes &#8211; Part 1</title>
		<link>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/</link>
		<comments>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 14:12:55 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=944</guid>
		<description><![CDATA[Its one of the biggest and most complex projects I have had to work on in a long time and I thought it was worth going through some of the key elements explain how we got it done. In regards to flash/actionscript there were two main areas to the site: the logic for building the [...]]]></description>
			<content:encoded><![CDATA[<p>Its one of the biggest and most complex projects I have had to work on in a long time and I thought it was worth going through some of the key elements explain how we got it done.</p>
<p><span id="more-944"></span></p>
<p>In regards to flash/actionscript there were two main areas to the site:</p>
<ul>
<li>the logic for building the sequence</li>
<li>content, tracking and data insertion</li>
</ul>
<p>I&#8217;ll give a bit of a run through each of these sections and explain some of the techniques used, but first a bit on info about how things were set up.</p>
<h3 id="intro">Quick Intro</h3>
<p>Before I actually began work on the project a lot of the Facebook elements had already been set up.  Erik, the lanky Swede I work with, had already created a bit of a shell for the site and created a Javascript bridge to handle all the logging in and gathering of user information.</p>
<p>Once the data was collected from Facebook it was marshalled into objects for use inside the app.  Each of the friends featured on the site had their names and profile pics collected, whilst the main user had their name, age, profile pic, some alternative profile pics (if available), a cropped profile pic and some pics from of their gallery.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/facebookToFlash.jpg" alt="Facebook to Flash Sequence" title="Facebook to Flash" width="567" height="216" class="alignnone size-full wp-image-957" /></p>
<p>Once I had all that information I could start building the sequence.</p>
<h3 id="generate">Generating the sequence</h3>
<p>The sequence of the story generated for each user always followed a similar story arc consisting of 9 main chapters &#8211; Introduction, Breakthrough, Rise, Fall, New Life, Comeback, Golden Years, Death and finally your Funeral. </p>
<p><img src="http://www.sevenson.com.au/content/uploads/Sequence1.jpg" alt="Sequence Thumbnails" title="Sequence" width="640" height="38" class="alignnone size-full wp-image-962" /></p>
<p>Each of those chapters was split up into 3 sections for the purpose of the logic. These were main videos, support segments/videos, and then a large collection of photos.</p>
<p>All this content was laid out in XML in a style that kind of related to this structure.  Each piece of content was marked up with a url to the content and the duration (there was bunch of other things, but for the purpose of generating sequences they were the main ones).</p>
<p><code class="as">&lt;chapter&gt;<br />
	&lt;main&gt;<br />
		&lt;segment duration="2"&gt;...<br />
		&lt;segment duration="1.5"&gt;...<br />
	&lt;/main&gt;<br />
	&lt;support&gt;<br />
		&lt;segment duration="2"&gt;...<br />
	&lt;/support&gt;<br />
	&lt;photos&gt;<br />
		&lt;segment duration="2"&gt;...<br />
	&lt;/photos&gt;<br />
&lt;/chapter&gt;<br />
</code></p>
<p>When I generated a new sequence, I would loop through each of the chapters and select 1 main video, 1 support segment, then as many photos as was needed to populate the required amount of time for that chapter.  I then ordered them so it would follow a sequence of Main Video, Some Photos, Support Segment/Video and then Remaining Photos.</p>
<p><img src="http://www.sevenson.com.au/content/uploads/chapters.jpg" alt="Chapter Layout" title="Chapter Layout" width="500" height="104" class="alignnone size-full wp-image-965" /></p>
<p>Sounds pretty simple huh?  Yeah. I thought so too. Then came some changes <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>After reviewing the content it became kinda clear that a totally random approach wasn&#8217;t going to work. Some elements just didn&#8217;t seem to fit with other elements, and others didn&#8217;t make sense without particular backup elements.  </p>
<p>A great example for this was the situation where the story took you to prison.  It didn&#8217;t make sense to show picture of the countryside when you were supposed to be in prison.  Conversely, it didn&#8217;t make sense to show pictures of prison when you were in a retirement home.</p>
<p>Sooo&#8230; what to do?  I had to make it smarter.</p>
<p>I added in some extra optional attributes to the XML and came up with a linking system to help tie it all together.</p>
<p>Firstly, I added in a &#8216;link&#8217; attribute where you could write in a keyword.  If an element was selected that had a &#8216;link&#8217; attribute, the link would be stored, and then any other segments with the same link would be given preference when the app was randomly selecting pieces.</p>
<p>That worked pretty well, but I needed a bit more control.  Thats when I created the &#8216;ignore&#8217; and &#8216;required&#8217; attributes.  If a segment has an &#8216;ignore&#8217; attribute and it matches a previously selected &#8216;link&#8217; attribute, it will be removed from the possible pieces that can be used.  In a similar fashion, a segment would not be considered for selection unless a previous segment with a matching link had already been selected.</p>
<p>To help prevent users being shown images that weren&#8217;t age appropriate to them, I added in &#8216;minage&#8217; and &#8216;maxage&#8217; attributes that would be compared to the user&#8217;s actual age.  If they were outside the range then they would also be ignored.</p>
<p>Finally, I added in an &#8216;order&#8217; attribute.  This was used to force some elements to appear before or after other elements.</p>
<p><code class="as">&lt;segment duration="2" link="jail" ignore="model" minage="30"&gt;<br />
	&lt;resources&gt;<br />
		&lt;item id="main"&#038;gtpath_to_video&lt;/item&gt;<br />
	&lt;/resources&gt;<br />
&lt;/segment&gt;<br />
</code></p>
<p>All this was done using the power of E4X and regular expressions.  I won&#8217;t go into the gritty details, but basically I did an E4X query on the XML to gather a list of possible segments, then did multiple calls on that list testing each of the conditions until I had either a filtered list to randomly select an item from, or an empty list which meant that there were no more suitable elements.</p>
<p>The code looked a little bit like this:</p>
<p><code class="as"><br />
// instance vars<br />
var regExp:RegExp = new RegExp([previous found links here])<br />
// inside method var list:XMLList;<br />
list = chapter.story.segment.( (hasOwnProperty('@link') &#038;&#038; regExp.test(@link)) || (hasOwnProperty('@required') &#038;&#038; regExp.test(@required));<br />
if(!list || list.length()==0) list = chapter.story.segment;<br />
// trim back the list<br />
list = list.(!hasOwnProperty('@ignore') || !regExp.test('@ignore'));<br />
list = list.(!hasOwnProperty('@minage') || Number('@minage') < user.age);<br />
list = list.(!hasOwnProperty('@maxage') || Number('@maxage') > user.age);<br />
// bail if there is nothing<br />
if(!list || list.length()==0) return null;<br />
// select a random segment from what is left<br />
var node:XML = list[ Math.floor(Math.random()*list.length()) ];<br />
// if this segment has a link attribute, add it to the reg exp now for future selections<br />
// delete this node from the xml so it cannot be selected again<br />
// return the selected node<br />
return node;<br />
</code></p>
<p>And that was that. I would just loop through each chapter, then through each subset of main images, photos, etc. selecting segments and generating a list.</p>
<p>Once I had a list it was onto the fun stuff &#8211; the actual content &#8211; but that will have to wait for another post because I&#8217;m really tired right now :p</p>
<p>You can read the second part by <a href="/actionscript/lynx-fastlife-behind-the-scenes-part-2/" title="Lynx Fastlife - Behind The Scenes - Part 2">clicking here</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/lynx-fastlife-behind-the-scenes-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Light Writing Effect</title>
		<link>http://www.sevenson.com.au/actionscript/light-writing-effect/</link>
		<comments>http://www.sevenson.com.au/actionscript/light-writing-effect/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 13:10:21 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Graphic Design]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=852</guid>
		<description><![CDATA[A while back I was given the task of trying to animate a banner that was to go on a site we were building at Visual Jazz. All in a usual days work I thought until I saw the design mockup and realised it had been photo-shopped to the bejeezus. The idea behind it was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/actionscript/light-writing-effect/attachment/lightwriting_icon/" rel="attachment wp-att-898"><img src="http://www.sevenson.com.au/content/uploads/lightwriting_icon.jpg" alt="" title="Light Writing Icon" width="248" height="183" class="alignright size-full wp-image-898" /></a>A while back I was given the task of trying to animate a banner that was to go on a site we were building at Visual Jazz.  All in a usual days work I thought until I saw the design mockup and realised it had been photo-shopped to the bejeezus.</p>
<p>The idea behind it was that it was meant to look like when you take a sparkler and move it around really fast in the air &#8211; the glow leaves a line of light behind it for a few seconds.</p>
<p>After a fair bit of messing around I finally came up with something I think looked pretty cool, which you can check out here&#8230;</p>
<p><span id="more-852"></span></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_swfloader_1622023065"
			class="flashmovie"
			width="600"
			height="400">
	<param name="movie" value="http://www.sevenson.com.au/content/common/swfloader.swf" />
	<param name="flashvars" value="contentURL=http://www.sevenson.com.au/content/actionscript/lightwriting/core.swf&amp;previewURL=http://sevenson.com.au/content/actionscript/lightwriting/mockup.jpg&amp;clickToLoad=true&amp;bgColour=#000000" />
	<param name="quality" value="high" />
	<param name="wmode" value="transparent" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.sevenson.com.au/content/common/swfloader.swf"
			name="fm_swfloader_1622023065"
			width="600"
			height="400">
		<param name="flashvars" value="contentURL=http://www.sevenson.com.au/content/actionscript/lightwriting/core.swf&amp;previewURL=http://sevenson.com.au/content/actionscript/lightwriting/mockup.jpg&amp;clickToLoad=true&amp;bgColour=#000000" />
		<param name="quality" value="high" />
		<param name="wmode" value="transparent" />
	<!--<![endif]-->
		
<div class="missingFlash">Demo should be here</div>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The way it works is kinda simple, but in a slightly complicated way&#8230;  if that makes sense..</p>
<p>Basically, I created a round BitmapData that would act as a &#8216;brush&#8217;. It was a simple circles with blurred edges.  I then had a second transparent BitmapData that would act a canvas for the brush to draw into.</p>
<p>Every frame of the animation I would check for a change in the brush position, and if it had moved I would draw a line between the two points with the brush.  Unfortunately, there isn&#8217;t a built in way to draw lines using a BitmapData so I used some basic math to divide up the line I wanted to draw into equal steps, then drew the brush BitmapData at each step along the line.</p>
<p>That gave me a basic soft edged brush effect, but it didn&#8217;t fade out over time.  That is where the BlurFilter comes in.</p>
<p>On every frame I would apply a BlurFilter to the canvas BitmapData &#8211; I can&#8217;t remember the exact amount, but it wasn&#8217;t too big.  By itself it didn&#8217;t do too much to the canvas, but by applying it every frame, the blur would accumulate and slowly fade the drawing out to transparent.</p>
<p>That&#8217;s the basic gist of it.</p>
<p>To make it look a bit cooler, I actually ran two versions of this effect over the top of each other &#8211; one for a soft glow, and the other for a hard edged central colour &#8211; I thought it gave it a nicer effect.  I also started adding in some basic scale changes depending on how fast the mouse was moving, so the lines would thin out on fast motions</p>
<p>You can download a FlashDevelop project here that has all of the assets I used &#8211; <a href="http://www.sevenson.com.au/wp-content/plugins/download-monitor/download.php?id=9" title="Downloaded 81 times">Light Writing Project</a></p>
<p>I think it looks pretty cool and it worked with the designs really well. Just to make things tricky though, they made be rebuild the whole effect using AS2 so that it could be used in some banner campaigns. I had forgotten how much better AS3 is <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/light-writing-effect/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/light-writing-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glowing Text Effect</title>
		<link>http://www.sevenson.com.au/actionscript/glowing-text-effect/</link>
		<comments>http://www.sevenson.com.au/actionscript/glowing-text-effect/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 12:12:55 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=854</guid>
		<description><![CDATA[The Lynx Fast Life campaign I worked on at Visual Jazz had a design style that was just screaming for more than just the usual blurs and fades you usually use on a flash website. Something that looked more like After Effects then flash. After a bit of messing around with prototypes I finally came [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/actionscript/glowing-text-effect/"><img src="http://www.sevenson.com.au/content/uploads/icon1.jpg" alt="" title="Glow Text" width="197" height="150" class="alignright size-full wp-image-928" /></a>The <a href="http://www.lynxfastlife.com" title="Lynx Fast Life">Lynx Fast Life</a> campaign I worked on at <a href="http://www.visualjazz.com.au" title="Visual Jazz">Visual Jazz</a> had a design style that was just screaming for more than just the usual blurs and fades you usually use on a flash website.  Something that looked more like After Effects then flash.</p>
<p>After a bit of messing around with prototypes I finally came up with something I thought looked pretty cool and it ended up getting used throughout the entire site.  </p>
<p><span id="more-854"></span></p>
<p>The effect was created by taking in a BitmapData of the text I wanted to reveal and then building around that.</p>
<p>First of all, I created two larger versions of the original BitmapData with extra transparency around them.  Then I added a GlowFilter to thicken them up a bit before applying a two different levels of BlurFilter to the BitmapDatas.</p>
<p>Next, I lined these up with the original BitmapData and used them as masks for a gradient filled shape I generated (everything was set to cacheAsBitmap so I could do alpha masking).  I animated the gradient through the blurred masks with a slight delay between them &#8211; this gave an effect of a tapering off type of brightness.<br />
<br clear="both"/><a href="http://www.sevenson.com.au/content/uploads/guide.jpg"><img src="http://www.sevenson.com.au/content/uploads/guide.jpg" alt="Guide to the mask level" title="Glowing Text File" width="544" height="399" class="alignleft size-full wp-image-905" /></a><br />
<br clear="both"/></p>
<p>After that I created a gradient filled mask for the original BitmapData which I used to reveal the base image behind the two blurred glows.  I had to play around with the timings a bit, but eventually came up with some values I thought worked pretty well.</p>
<p>Finally, just for a touch of class, I added in another small gradient to act as a shine to the text.  It used an instance of the the original BitmapData as a mask and simple past over the length of the text a second or so behind the reveal.  </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_swfloader_1278843965"
			class="flashmovie"
			width="550"
			height="150">
	<param name="movie" value="http://www.sevenson.com.au/content/common/swfloader.swf" />
	<param name="flashvars" value="contentURL=http://www.sevenson.com.au/content/actionscript/glowtext/core.swf&amp;previewURL=http://sevenson.com.au/content/actionscript/glowtext/mockup.jpg&amp;clickToLoad=true&amp;bgColour=#000000" />
	<param name="quality" value="high" />
	<param name="wmode" value="transparent" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.sevenson.com.au/content/common/swfloader.swf"
			name="fm_swfloader_1278843965"
			width="550"
			height="150">
		<param name="flashvars" value="contentURL=http://www.sevenson.com.au/content/actionscript/glowtext/core.swf&amp;previewURL=http://sevenson.com.au/content/actionscript/glowtext/mockup.jpg&amp;clickToLoad=true&amp;bgColour=#000000" />
		<param name="quality" value="high" />
		<param name="wmode" value="transparent" />
	<!--<![endif]-->
		
<div class="missingFlash">Demo should be here</div>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>And that was that &#8211; my pretty cool glowing text reveal effect thingy.</p>
<p>For the transition out of the text I did something a bit different.  I wanted the text to decay away, but I didn&#8217;t really have a lot of time to get the effect right. What I came up with was a bit of a Frankenstein approach that generated an interesting result.</p>
<p>I started by creating a bit of a mask/guide in an off-stage Sprite.  It consisted of a BitmapData generated from Perlin Noise as a base, and a gradient-filled shape that was big enough to cover the perlin noise base.</p>
<p>I then set up another BitmapData as a mask for the original text.</p>
<p>Here comes the fun part.  I animated the gradient mask in my guide sprite to slowly slide across the perlin noise. As I was doing this, I did a BitmapData.draw() of the mask/guide into the BitmapData mask of the text, using BlendMode.MULTIPLY as the blend mode.  This caused the the areas of the perlin noise that were revealed by the gradient to build up in the mask, hence slowly hiding chunks of the original text.</p>
<p>I hope that makes sense &#8211; I am pretty tired as I write this.</p>
<p>And there you have it &#8211; the glowing text effect with an added perlin noise dissolve thrown in for free.  Hope you enjoyed it <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here is the code &#8211; it&#8217;s not pretty, but should show you how it was all done &#8211; <a href="http://www.sevenson.com.au/wp-content/plugins/download-monitor/download.php?id=8" title="Downloaded 92 times">Glow Text Class</a></p>
<p>You will need to download a couple of support classes &#8211; namely TweenMax from <a href="http://www.greensock.com/tweenmax/" title="TweenMax by Greensock">Greensock</a>, and the ColorMatrix class from <a href="http://www.quasimondo.com/">Quasimondo</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/glowing-text-effect/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/glowing-text-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lynx Fastlife goes live!</title>
		<link>http://www.sevenson.com.au/ramblings/lynx-fast-life-goes-live/</link>
		<comments>http://www.sevenson.com.au/ramblings/lynx-fast-life-goes-live/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 13:45:46 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=857</guid>
		<description><![CDATA[For the last few weeks I have been working on a pretty massive project at Visual Jazz for Lynx body spray called Lynx Fast Life. It is a pretty awesome video / facebook / integration site that pulls data from your Facebook account and generates a glimpse of what your life would have been like [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/ramblings/lynx-fast-life-goes-live/"><img src="http://www.sevenson.com.au/content/uploads/Lynx-Thumbnail.jpg" alt="" title="Lynx Fast Life" width="292" height="104" class="alignright size-full wp-image-864" /></a>For the last few weeks I have been working on a pretty massive project at <a href="http://www.visualjazz.com.au" title="Visual Jazz">Visual Jazz</a> for Lynx body spray called <a href="http://www.lynxfastlife.com/" title="Lynx Fast Life">Lynx Fast Life</a>.</p>
<p>It is a pretty awesome video / facebook / integration site that pulls data from your Facebook account and generates a glimpse of what your life would have been like if the world wasn&#8217;t going to end in 2012.</p>
<p>It was a massive effort from a number of people from different agencies and it all came together beautifully in the end.</p>
<p>I will be doing a bit of a write up on some of the technical stuff I had to deal with soon, but in the mean time be sure to go and check it out at <a href="http://www.lynxfastlife.com/" title="Lynx Fast Life">http://www.lynxfastlife.com/</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/ramblings/lynx-fast-life-goes-live/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/ramblings/lynx-fast-life-goes-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bananas in Pyjamas Website</title>
		<link>http://www.sevenson.com.au/showcase/bananas-in-pyjamas/</link>
		<comments>http://www.sevenson.com.au/showcase/bananas-in-pyjamas/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 13:51:03 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Online Showcase]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Alternativa]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Kids]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=859</guid>
		<description><![CDATA[A little while back Visual Jazz was awarded the job of creating a website for the newly revamped Bananas in Pyjamas &#8211; a childrens TV show created by the ABC The concept was to create a section of Cuddles Town &#8211; the home town of the Bananas and all their friends &#8211; using the new [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/showcase/bananas-in-pyjamas/"><img src="http://www.sevenson.com.au/content/uploads/icon.jpg" alt="" title="Bananas In Pyjamas Icon" width="300" height="200" class="alignright size-full wp-image-872" /></a>A little while back <a href="http://www.visualjazz.com.au/#/portfolio/bananas_in_pyjamas" title="Visual Jazz" target="_blank">Visual Jazz</a> was awarded the job of creating a website for the newly revamped Bananas in Pyjamas &#8211; a childrens TV show created by the <a href="http://www.abc.net.au/" title="ABC" target="_blank">ABC</a></p>
<p>The concept was to create a section of Cuddles Town &#8211; the home town of the Bananas and all their friends &#8211; using the new design style of the revamped show.</p>
<p><span id="more-859"></span></p>
<p><a href="http://www.sevenson.com.au/content/uploads/day.jpg"><img src="http://www.sevenson.com.au/content/uploads/day-300x236.jpg" alt="" title="Cuddles Town" width="300" height="236" class="alignleft size-medium wp-image-870" /></a>The design gurus I work with at VJ came up with a pretty awesome horizontal layout for the entire town, with each of the characters from the show being represented in the scene.</p>
<p>Each of the characters houses represented an area to explore, with some areas containing information about the show, and others containing fun little games for the kids to play.<br />
<br/><br />
<a href="http://www.sevenson.com.au/content/uploads/closeup.jpg"><img src="http://www.sevenson.com.au/content/uploads/closeup-300x236.jpg" alt="" title="Banana&#039;s House Close-up" width="300" height="236" class="alignright size-medium wp-image-869" /></a>To give the world a bit of depth, we built the entire scene in a parallaxing style using Alternativa3D. All of the hills were laid out on planes and when the user clicked on a hot spot, the camera would zoom into the area to reveal extra details, etc.</p>
<p><br clear="both"/><br />
<a href="http://www.sevenson.com.au/content/uploads/topsy.jpg"><img src="http://www.sevenson.com.au/content/uploads/topsy-300x236.jpg" alt="" title="Topsys Dance Along" width="300" height="236" class="alignleft size-medium wp-image-877" /></a>A few of the sections had some small games and activities for the user toe play with.  Each was a little different and tied in with the site quite well.</p>
<p>Topsy&#8217;s area contained a dance along game where the user had to click the mouse or press the space bar in time with the music.  If the timing was correct, Topsy would dance along.  There was also the option of just playing the songs and watching Topsys dance without the need to press any buttons.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/charlie.jpg"><img src="http://www.sevenson.com.au/content/uploads/charlie-300x236.jpg" alt="" title="Charlie&#039;s Machine" width="300" height="236" class="alignleft size-medium wp-image-868" /></a>Charlie&#8217;s area contained a game where the user had to fix the machine by selecting the piece that matched the missing shape.  If completed correctly, the user was awarded with an award of a colour in printout of the object the machine generated.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/bernards.jpg"><img src="http://www.sevenson.com.au/content/uploads/bernards-300x236.jpg" alt="" title="Barnards Story Time" width="300" height="236" class="alignleft size-medium wp-image-867" /></a>Bernards house contained a story book where the user could select from one of three possible stories to read along with. Each of the stories were narrated by the Banana&#8217;s and had actual sound samples from the episodes.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/dressup.jpg"><img src="http://www.sevenson.com.au/content/uploads/dressup-300x236.jpg" alt="" title="Dress-Up Game" width="300" height="236" class="alignleft size-medium wp-image-871" /></a>The Banana&#8217;s area had two games.  One was a simple dress-up game where you could select clothing for the Banana&#8217;s to wear.  There is also a simple treasure hunt game where the user is given the task of finding items hidden around Cuddles Town.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/watch.jpg"><img src="http://www.sevenson.com.au/content/uploads/watch-300x236.jpg" alt="" title="Watch Section" width="300" height="236" class="alignright size-medium wp-image-878" /></a>Other areas of the site contained other types of information for the user.  One area contained the &#8216;Watch&#8217; section where the user could watch various episodes from the TV show streamed directly from the ABC.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/make.jpg"><img src="http://www.sevenson.com.au/content/uploads/make-300x236.jpg" alt="" title="Make Section" width="300" height="236" class="alignright size-medium wp-image-873" /></a>The &#8216;Make&#8217; section contained a number of various printouts and activities that the user could use to create heaps of different things such as gift cards, colouring-in pictures and photo frames.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/meet.jpg"><img src="http://www.sevenson.com.au/content/uploads/meet-300x236.jpg" alt="" title="Meet section" width="300" height="236" class="alignright size-medium wp-image-874" /></a>The &#8216;Meet&#8217; section contained a small bio on each of the characters from the show.  There was also a small animation of each of the characters introducing themselves.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/night.jpg"><img src="http://www.sevenson.com.au/content/uploads/night-300x236.jpg" alt="" title="Night time in Cuddles Town" width="300" height="236" class="alignleft size-medium wp-image-875" /></a>As a nice little touch we added in a night-time mode for the town where the sun went down and all of the houses lights came on.</p>
<p>This feature was later extended to &#8216;sleep time&#8217; where a parent could set a timer on the site so that after a certain amount of time the entire site would go to sleep preventing any further interaction stopping the child for playing for too long.<br />
<br clear="both"/><br />
So that&#8217;s the Banana&#8217;s site in a nutshell.  It was a lot of fun to build and I had a lot of help putting together all the games.  It was also my first project where I used Alternativa3D which was also a bit of fun.</p>
<p>I don&#8217;t think I need to mention it, but all the characters etc. are the respective property of their owners.</p>
<p>If you get the chance you should go check out the site by <a href="http://www.abc.net.au/abcforkids/sites/bananasinpyjamas/" title="Bananas in Pyjamas" target="_blank">clicking here</a>.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/showcase/bananas-in-pyjamas/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/showcase/bananas-in-pyjamas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I got hacked</title>
		<link>http://www.sevenson.com.au/ramblings/i-got-hacked/</link>
		<comments>http://www.sevenson.com.au/ramblings/i-got-hacked/#comments</comments>
		<pubDate>Sun, 08 May 2011 08:46:04 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Ramblings]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=836</guid>
		<description><![CDATA[Sigh. Why someone would want to hack my site, I don&#8217;t know. Looked like they were trying to redirect some traffic their way. Hopefully I have patched up everything now &#8211; I guess I&#8217;ll find out soon enough if I haven&#8217;t :p Sorry to anyone that may have been effected by the site being down. [...]]]></description>
			<content:encoded><![CDATA[<p>Sigh.</p>
<p>Why someone would want to hack my site, I don&#8217;t know.  Looked like they were trying to redirect some traffic their way.</p>
<p>Hopefully I have patched up everything now &#8211; I guess I&#8217;ll find out soon enough if I haven&#8217;t :p</p>
<p>Sorry to anyone that may have been effected by the site being down.  Hopefully there will be some new posts coming soon</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/ramblings/i-got-hacked/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/ramblings/i-got-hacked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Warfare Officer and Strike Fighter for iPhone</title>
		<link>http://www.sevenson.com.au/ramblings/warfare-officer-and-strike-fighter-for-iphone/</link>
		<comments>http://www.sevenson.com.au/ramblings/warfare-officer-and-strike-fighter-for-iphone/#comments</comments>
		<pubDate>Tue, 03 May 2011 09:12:59 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=797</guid>
		<description><![CDATA[Two of the flash games I have created for the DefenceJobs Games site have been fully reworked and for the iPhone and iPad. Yay! Some of the clever guys I work with at Visual Jazz (looking at you Tom) have taken my AS3 code and reworked it to play nice with Apples nifty little machines. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/ramblings/warfare-office…ter-for-iphone/"><img src="http://www.sevenson.com.au/content/uploads/2010/11/03/iphone.jpg" alt="" title="iPhone Warfare Officer" width="350" height="190" class="alignright size-full wp-image-801" /></a>Two of the flash games I have created for the <a href="http://http://games.defencejobs.gov.au/">DefenceJobs Games</a> site have been fully reworked and for the iPhone and iPad.  Yay!</p>
<p>Some of the clever guys I work with at <a href="http://www.visualjazz.com.au/">Visual Jazz</a> (looking at you Tom) have taken my AS3 code and reworked it to play nice with Apples nifty little machines.  Best of all, you can download them for free!</p>
<p><span id="more-797"></span></p>
<p><a href="http://itunes.apple.com/us/app/strike-fighter/id389734422?mt=8"><img src="http://www.sevenson.com.au/content/uploads/2010/11/04/sf-logo1.jpg" alt="" title="Strike Fighter iPhone icon" width="175" height="175" class="alignleft size-full wp-image-804" /></a>Strike Fighter was the first one done &#8211; it is only available for the iPhone at the moment. You can check it out by going here: <a href="http://itunes.apple.com/us/app/strike-fighter/id389734422?mt=8">http://itunes.apple.com/us/app/strike-fighter/id389734422?mt=8</a><br />
<br clear="both"/><br />
<a href="http://itunes.apple.com/ca/app/navy-warfare-officer/id393458494?mt=8"><img src="http://www.sevenson.com.au/content/uploads/2010/11/04/warfare-logo2.jpg" alt="" title="warfare officer logo" width="175" height="175" class="alignleft size-full wp-image-803" /></a>Warfare officer has been completed more recently. It has been set up for both iPhone and iPad and can be checked out here: <a href="http://itunes.apple.com/ca/app/navy-warfare-officer/id393458494?mt=8">http://itunes.apple.com/ca/app/navy-warfare-officer/id393458494?mt=8</a></p>
<p>Be sure to check them out!</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/ramblings/warfare-officer-and-strike-fighter-for-iphone/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/ramblings/warfare-officer-and-strike-fighter-for-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AVM1 in AVM2 Woes</title>
		<link>http://www.sevenson.com.au/actionscript/avm1-in-avm2-woes/</link>
		<comments>http://www.sevenson.com.au/actionscript/avm1-in-avm2-woes/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 22:48:43 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=815</guid>
		<description><![CDATA[Not too long ago I was given the task of making some old AS1 and AS2 games work inside a brand new AS3 site that we had built for a client. Whilst the basic concept seemed simple enough &#8211; load it in with a Loader &#8211; I soon realised there were a bunch of problems [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/actionscript/avm1-in-avm2-woes/"><img src="http://www.sevenson.com.au/content/uploads/2010/11/04/AVM1-AVM2-300x142.jpg" alt="" title="AVM1-AVM2 Image" width="300" height="142" class="alignright size-medium wp-image-816" /></a>Not too long ago I was given the task of making some old AS1 and AS2 games work inside a brand new AS3 site that we had built for a client.  Whilst the basic concept seemed simple enough &#8211; load it in with a Loader &#8211;  I soon realised there were a bunch of problems that needed to be addressed &#8211; most of which I couldn&#8217;t find any information on.</p>
<p>For the sake of others I have compiled a list of these here, along with the solutions I found, when there was one.<br />
<span id="more-815"></span></p>
<hr/>
<h2>Levels are bad</h2>
<p>I don&#8217;t know why, but they just don&#8217;t seem to work right.  To get around it, I replaced I loaded external movies into the _root level, and then manuallky changed all the _levelN references.  That was lots of fun.  Good luck with that.</p>
<h2>globalToLocal() may not work</h2>
<p>This is a bit of a strange one.  There appears to be a bug in conversion when the Loader that you use to load in the AVM1 file is positioned anywhere other than 0,0. Looking at the numbers it is almost like the position is offset by whatever amount the Loader is offset by.</p>
<p>Work around?  Nothing really fun.  You could write your own conversion thing that recursively climb up the _parent() tree &#8211; that&#8217;s all I came up with</p>
<h2>MovieClip.hittest()</h2>
<p>This seems to be related to the globalToLocal() bug in that the collision position is offset by the Loader offset.  If you are just using the MovieClip.hittest(MovieClip) method, it will work fine because the co-ords are messed up fro both objects.  Where it really fails though is when you are using the MovieClip.hittest(x,y,shape) approach.  That just doesn&#8217;t play nice at all.</p>
<p>Steve, a guy I work with at VJ, came up with a bit of a work around.  Basically you take the bounds of the object you are testing and then compare it to the point you want.  This means you miss out on the shape flag, but it was good enough for a lot of the things I was doing.</p>
<h2>Static classes / variables &#8211; (Updated &#8211; see note at end)</h2>
<p>I still haven&#8217;t figured this one out fully yet, but there does seem to be a problem with static variables, etc.</p>
<p>One of the projects I was updating was using a Singleton style approach to one of its classes.  It all worked fine the first time you loaded it in, but when you unloaded and reloaded it, it would fail.</p>
<p>I poked around for a fair while and I discovered that the class reference was staying in memory despite the AVM1 file being closed and unloaded.  They by itself wasn&#8217;t that bad.  The real issue was that the reference to _root and _global inside that class was totally lost.</p>
<p>Don&#8217;t get me wrong, _root and _global still exist in the project, but the static classes just didn&#8217;t see them at all &#8211; they kept coming up as null.</p>
<p>The work around for this wasn&#8217;t very elegant, but the only way we could get this to work was to pass in the _root reference to the static classes via an .init() call.  Like I said, not pretty, but after a couple hours of experimenting it was the only thing that worked.</p>
<p><b>UPDATE</b>  This is just a quick update &#8211; I did a bit more research and it would appear that this bug is worse then I first thought.  It has nothing to do with static classes and more to do with a bug in the player.  Check out this <a href="http://bugs.adobe.com/jira/browse/FP-2804">bug notice</a> on the adobe site, then pull a sad face if it is effecting you&#8230;. I know I will <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<hr/>
<p>That&#8217;s the list so far &#8211; if I find any others I will add them in as I go.  Hopefully it will save people a bit of time.</p>
<p>source : <a href="http://tugaskita.com/">www.tugaskita.com</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/avm1-in-avm2-woes/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/avm1-in-avm2-woes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Warfare Officer &#8211; Behind The Scenes</title>
		<link>http://www.sevenson.com.au/actionscript/warfare-officer-behind-the-scenes/</link>
		<comments>http://www.sevenson.com.au/actionscript/warfare-officer-behind-the-scenes/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 06:24:02 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=735</guid>
		<description><![CDATA[Warfare Officer is the biggest game I have built to date. Built in Flash using Away3D lite, it used a variety of techniques that I have never used before. It was a bit of a min Here is a quick summary of some of the techniques I used when building this game. Performance The first [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/actionscript/warfare-office…ind-the-scenes/"><img src="http://www.sevenson.com.au/content/uploads/2010/10/15/HeroImageBehindScene-300x162.jpg" alt="" title="Warfare Officer - Behind The Scenes" width="300" height="162" class="alignright size-medium wp-image-737" /></a>Warfare Officer is the biggest game I have built to date.  Built in Flash using Away3D lite, it used a variety of techniques that I have never used before.  It was a bit of a min</p>
<p>Here is a quick summary of some of the techniques I used when building this game.<br />
<span id="more-735"></span></p>
<h2>Performance</h2>
<p>The first thing I had to figure out was how to manage all of the models and assets for the game.  I knew there would be a lot of 3D going on &#8211; which is not exactly flash&#8217;s strong point.  </p>
<p>Initially I started out by setting up a basic camera controller and loading in as many models as I thought I would need.  This gave me an indication of what level of detail I could get away with without sacrificing too much detail. This formed the basis for pretty much the rest of the game development.</p>
<p>The next thing I played with was the frame rate. Originally I ran the entire program at 60fps, which was awesome, but as I added in more and more features I discovered that it was pushing the CPU pretty hard.<br />
I dropped the frame rate back down to 30fps which made little difference to the visual display of the game elements, but unfortunately made the UI elements seem a bit sluggish. </p>
<p>To get around it this problem, I split the game up into a variety of different renderers, each running at the minimum speed possible.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetCommanderLayers.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetCommanderLayers.jpg" alt="" title="Fleet Commander Render Layers" width="605" height="182" class="alignleft size-full wp-image-778" /></a></p>
<p>The render layer used for the for the GUI elements were set up to run at 60fps, whilst the &#8216;boats / islands&#8217; and &#8216;water&#8217; layer ran at a much slower 25fps.  There was also an under water layer for a while when I had transparent water, but that had to be removed due to performance issues.</p>
<p>A unexpected positive side effect of this approach was that it prevented a lot of the clipping problems that were occurring between the boats and the water.</p>
<h2>Ripple Effects</h2>
<p>The ripples around the boats and islands were created by putting a simple 3D plane under the loaded in MD2 models. The benefits of this approach was that it allowed me to keep the complexity of the MD2 model down a bit, as well as making it easy to edit and animate the texture. </p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetCommanderRipples.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetCommanderRipples.jpg" alt="" title="Warfare Officer Ripples" width="584" height="172" class="alignleft size-full wp-image-781" /></a></p>
<p>Having a plane for the ripples under the boat came in handy for the collision detection as well.  It game me a simple shape to check projectile collisions against (there is another invisible vertical one as well).</p>
<h2>Explosions</h2>
<p>The explosions were a key part to the game.  We wanted them to be big and look awesome, but at the same time we were limited by the rendering powers of flash.</p>
<p>We decided to take a billboard approach, which is basically some planes that would always face the camera.  Usually this technique looks pretty flat, so I experimented with some different styles and finally came up with a way that I think looked pretty good.</p>
<p>The 3D / After Effects guys created and rendered out some explosion animations that were split into two parts &#8211; the main explosion and the flat ripple effect on the water.  I created an object that had two similar planes &#8211; one for the ripple and one for the explosion. The ripple laid flat on the ocean and never moved, whilst the main explosion rotated around a point at the base, an was angled to face the camera.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetExplosion.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/11/02/FleetExplosion.jpg" alt="" title="Warfare Officer Explosion" width="404" height="153" class="alignleft size-full wp-image-784" /></a> Depending on the explosion animation, the pivot point would sometimes be moved to compensate for alignment issues.<br />
<br clear="both"/><br />
To make it look better, I got the 3D guys to render out explosion animation from an angle that was similar to that used by the games camera.  This helped give the explosions the look of volume and depth.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/16/Explosion2.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/16/Explosion2-300x197.jpg" alt="" title="Explosion" width="300" height="197" class="alignright size-medium wp-image-759" /></a>Although technically the perspective is not quite correct, it is only really noticeable when the explosions are in the closest corners of the view.</p>
<h2>Path finding</h2>
<p>Path finding was a big part of Warfare Officer &#8211; and a part I put off for too long because of fear&#8230;  I had never done any kind of path finding before so it was all a learning experience.</p>
<p>I did some reading and found a really good post explaining the A* path finding technique &#8211; <a href="http://www.policyalmanac.org/games/aStarTutorial.htm">A* Pathfinding for Beginnners</a>.  It explained the technique very well and I was able to knock up my own basic system one Sunday afternoon.</p>
<p>I soon had the boats moving around the world following the A* grid, but it didn&#8217;t look quite natural.  This was mainly because the ships would move to the centre of each grid cell, moving in an almost robotic manner.  I set about figuring out a way to smooth out the path to make it a bit smoother and more boat like.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/11/02/AStar-Smooth.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/11/02/AStar-Smooth.jpg" alt="" title="AStar-Smoothing" width="402" height="252" class="alignleft size-full wp-image-785" /></a></p>
<p>The technique I came up with was to start by generating the A* path.  Then I would draw a line from the first node to each subsequent node until I hit an obstacle.  If an obstacle was hit, I would store the last point I reached, before starting the process again from this new point.  </p>
<p>What I ended up with was a path that smoothed out a lot of the diagonal movements, making the boats move in a much more direct manner.</p>
<h2>Artificial Intelligence</h2>
<p>AI is another one of those things I had never attempted. For a first attempt, I think that the computer puts up a pretty good fight.</p>
<p>My approach was to break the AI into two separate parts that worked together &#8211; a boat AI and a master AI.</p>
<p>The master AI would run over everything about every 10-15 seconds looking at everything the boats and base could see and figure out a basic game plan.  In most cases this would be to have one ship patrol the defensive third of the map, whilst the other two wander out towards the enemy base.  The AI would sometimes call for a full on charge at the enemy base when it recognised that the defenses were weak.</p>
<p>The boats would take the master AI&#8217;s objective for them and then decide what exactly they would do.  If there was an enemy ship near by they may choose to ignore them or engage depending on what their weapon status.  The would also occasionally focus all their attention on the enemy base which helped make them a bit less predictable.</p>
<p>When a boat AI engaged the player it would loop through all of its available weapons and would test to see what had a chance of actually hitting them.  Once a collection of possibly successful weapons was collated, it would choose one at random, then attempt to fire it.  </p>
<p>The position that the AI would aim for was based on the position of the players boat, with a random X and Y  value applied to make it slightly less accurate.</p>
<p>To try and make the battle a bit more even, the enemy ships use a slightly shorter range on all weapons.  I found that this was necessary to give the user time to engage computer, otherwise they would usually die before they even had a chance to fire.</p>
<p>To stop the game from &#8216;cheating&#8217; the AI tracks the player&#8217;s boats itself rather than using data from the actual game.  It stores the last known position of each boat based on what it can see, so if the player destroys a ship, the AI will store that position as the last known position of the enemy and may consider sending a ship there to seek revenge.</p>
<p>In the end, the whole thing runs of a complex set of if/then statements and is governed by a bunch of random number calls to make decisions.  I basically just kept plugging in values until I got a result I was happy with.</p>
<p>That sums up most of the main parts of the game.  I hope it has given some insight into how some of the systems work.  If you have any questions about a particular part, please feel free to post a comment and I will get back to you!</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: left; margin-right: 10px; margin-left:60px;"><g:plusone size="medium" count="" href="http://www.sevenson.com.au/actionscript/warfare-officer-behind-the-scenes/">{lang: 'en-GB'}</g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/warfare-officer-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

