<?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 &#187; AS3</title>
	<atom:link href="http://www.sevenson.com.au/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sevenson.com.au</link>
	<description>The online presence of Andrew Sevenson</description>
	<lastBuildDate>Tue, 11 Oct 2011 10:53:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>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>
]]></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>
]]></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/content/uploads/lightwriting_icon.jpg"><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_574033013"
			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_574033013"
			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 47 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>
]]></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/content/uploads/icon1.jpg"><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_1901818985"
			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_1901818985"
			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 48 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>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/glowing-text-effect/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/content/uploads/2010/11/04/AVM1-AVM2.jpg"><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>
]]></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/content/uploads/2010/10/15/HeroImageBehindScene.jpg"><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>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/warfare-officer-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Warfare Officer</title>
		<link>http://www.sevenson.com.au/showcase/warfare-officer/</link>
		<comments>http://www.sevenson.com.au/showcase/warfare-officer/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 04:22:43 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Online Showcase]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=730</guid>
		<description><![CDATA[Warfare Officer is a bizzarre mix of real-time strategy and arcade explosiveness (if there is such a thing). Take control of three Australian navel ships and lead them on a mission to destroy the enemy base whilst protecting your own. When you first start up the game you are requested to select a fleet for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/15/HeroImage.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/15/HeroImage-300x162.jpg" alt="Hero image for the Warfare Officer game" title="Warefare Officer Hero Image" width="300" height="162" class="alignright size-medium wp-image-732" /></a>Warfare Officer is a bizzarre mix of real-time strategy and arcade explosiveness (if there is such a thing).  </p>
<p>Take control of three Australian navel ships and lead them on a mission to destroy the enemy base whilst protecting your own. </p>
<p><span id="more-730"></span></p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/16/UnitSelect.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/16/UnitSelect-300x196.jpg" alt="" title="Warfare Officer - Fleet Select Screen" width="300" height="196" class="alignleft size-medium wp-image-750" /></a><a href="http://www.sevenson.com.au/content/uploads/2010/10/16/UnitCustom.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/16/UnitCustom-300x198.jpg" alt="" title="Warfare Officer - Customisation Screen" width="300" height="198" class="alignleft size-medium wp-image-752" /></a>When you first start up the game you are requested to select a fleet for your battle.  You are initially presented with 3 preset fleets &#8211; Offensive, Defensive or Balanced.  Each fleet is made up of three different vessels from a collection of Australian navel vessels &#8211; an Armidale Class Patrol Boat, Anzac Class Frigate, Collins Class Submarine, Hobart Class Air Warfare Destroyer or a Canberra Class Landing Helicopter Dock.</p>
<p>Each vessel has its own set of attributes in regards to speed and strength.  Some also have some extra features such as support vehicles. Each select vessel also has an Australian Navy personnel member assigned to it which provides the vessel with an extra feature, such as better defences or a support craft.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/16/BeginScreen.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/16/BeginScreen-300x196.jpg" alt="" title="Game Begin Screen" width="300" height="196" class="alignright size-medium wp-image-757" /></a><a href="http://www.sevenson.com.au/content/uploads/2010/10/16/Shield.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/16/Shield-300x197.jpg" alt="" title="Shield" width="300" height="197" class="alignright size-medium wp-image-758" /></a><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>After that, the game begins. You are given control of your three vessels and pointed in the direction of the enemy base.</p>
<p>The goal of the game is to find and destroy the enemy base before they destroy yours.  The map is filled with a number of islands so it is not too difficult to sneak past your enemy without getting into a conflict.</p>
<p>To control a ship you simply click on it with your mouse.  Once selected, a list of possible actions are displayed along the bottom of the screen (with move being the default action). </p>
<p>Selecting an action will either carry it out straight away, or trigger a targeting radius showing the area in which the action can be carried out. </p>
<p>If one of your ships is destroyed in battle, it will be reconstructed after a period of time &#8211; as will your enemies ships.  it is important to take advantage of this time because the ships will be rebuilt at their base and are made invincible for a short period of time. </p>
<p>There is a single player campaign where you go up against a rather ruthless computer opponent &#8211; or a multiplayer game where the enemy is controlled by another player.  Both are online now and playable at <a href="http://games.defencejobs.gov.au/#/games/warfareofficer">Defence Jobs</a>.</p>
<p>This was the second major game I got to build for <a href="http://games.defencejobs.gov.au/#/games/warfareofficer">defencejobs.gov.au</a> whilst working at <a href="http://www.visualjazz.com.au">Visual Jazz</a> and it was definitely the biggest game I have ever worked on. </p>
<p>Source : <a href="http://tugaskita.com/">www.tugaskita.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/showcase/warfare-officer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strike Fighter &#8211; Behind the scenes</title>
		<link>http://www.sevenson.com.au/actionscript/strike-fighter-behind-the-scenes/</link>
		<comments>http://www.sevenson.com.au/actionscript/strike-fighter-behind-the-scenes/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 13:27:59 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Away3D]]></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=716</guid>
		<description><![CDATA[So, how was Strike Fighter built? Well, for starters it is all done in flash, which I think would be kinda obvious since that is what I tend to work with. The rest was a combination of some basic 3D and a few little tricks. To find out more, read on A lot of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/15/GameBehindTheSceneTile.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/15/GameBehindTheSceneTile-300x167.jpg" alt="" title="Fleet Commander Behind The Scene" width="300" height="167" class="alignright size-medium wp-image-718" /></a>So, how was Strike Fighter built?  Well, for starters it is all done in flash, which I think would be kinda obvious since that is what I tend to work with.</p>
<p>The rest was a combination of some basic 3D and a few little tricks.  To find out more, read on <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-716"></span></p>
<p>A lot of the inspiration for the coding side of things came from the <a href="http://flash-games.wonderfl.net/blog/2010/07/abc-flyer.html">ABC Flyer</a> experiment over at wonderfl.net.  It was a very simple little experiment that went a long way to setting up what became Strike Fighter.</p>
<p>The original ABC flyer used a pretty insane custom 3D stuff which was well above my head.  I got the jist of a lot of it, but not enough to be able to work with efficiently, so I started looking for an alternative.</p>
<p>Around the time that I started, Away3D lite (<a href="http://away3d.com/">away3d.com/</a>) came out. Up until that time I had only ever used PaperVision 3D, but I kinda wanted something smaller and faster to keep the game running smoothly.  I found Away3D Lite to be really easy to use and was soon up and running with a demo similar to the wonderfl example.</p>
<h2>The Main Scene</h2>
<p>The main scene for the game was made up from a combination of 3D planes laid out at about 90 degrees, with one main plane for the ground, and another two set up for the background / horizon.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/10/15/SceneSetup.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/15/SceneSetup.jpg" alt="" title="Strike Fighter Scene Setup" width="577" height="198" class="alignnone size-full wp-image-721" /></a></p>
<p>The ground plane was simply one big plane that had a bitmap texture applied.  When simulating the motion I used a technique I picked up from the ABC Flyer &#8211; offset the bitmap rather than moving the plane.  This proved to be much more efficient and gave a better result.</p>
<p>The background / horizon was originally set up as one large single plane, but because I used a texture that faded out to transparency I noticed that there was a bit of a slow down.  I ended up splitting it into two planes, with the major area using a non-transparent texture, and a much smaller plane for the graduated fade.  The visual look what pretty much identical with a noticeable performance increase.</p>
<p>All of these elements were then placed inside a container so that I could rotate and tilt the entire world when the jet banked etc.</p>
<h2>The F35 Jet</h2>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/08/05/NightAfterburn.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/NightAfterburn-300x202.jpg" alt="" title="Night Afterburn" width="300" height="202" class="alignright size-medium wp-image-679" /></a>The model of the F35 jet was a 3D model that the 3D guys at VJ built. I added in a 3D cone at runtime to act as the flame for the After Burner which I simply scaled up and down to suit the speed.  I also added in some contrails to the wing tips by generating a series of semi-transparent white planes that were laid out to form a line &#8211; (this was done using the missile smoke technique I explain later)</p>
<p>To make the jet change colour to suit the scene I simply applied a predefined ColourTransform to the BitmapData used for the jet&#8217;s texture.  This of course lead to the rather stupid problem of the jet&#8217;s engine flame being tinted as well.  To get around this, I measured up the exact spot in the texture where the engine was and reapplied the original colours from that area to the tinted version I had created.  </p>
<h2>Missiles</h2>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/08/05/DesertMissile.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/DesertMissile-300x202.jpg" alt="" title="Strike Fighter Desert Missile" width="300" height="202" class="alignright size-medium wp-image-674" /></a>The missile were one of the more challenging things to get working the way I wanted. </p>
<p>I started by trying a few simple ideas on how to simulate the motion of a missile, but they all tended to look too circular in their motion.  Then I started searching the web for some ideas &#8211; it took ages to find something that worked, and it took even longer to tweak it until it suited my game.  I would normally link to the site now, but I don&#8217;t know where I got it from &#8211; most likely gamedev.net.</p>
<p>Once I had the motion working, I started on the graphics.  The idea was to draw some planes along the path to generate the smoke trail. This was simple enough to do, but it hit a couple of major problems.</p>
<p>Firstly, the sheer number of planes I was creating / destroying meant that the CPU took a pretty big hit once you started firing lots of missile.  To get around this I came up with a pretty simple solution.  Each smoke trail would only ever have 5 planes created for it.  It would stretch and recycle these planes for the life of the trail.<br />
<a href="http://www.sevenson.com.au/content/uploads/2010/10/15/PathDescription.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/10/15/PathDescription.jpg" alt="Image showing the way in which I created trails of smoke" title="Smoke Path Description" width="553" height="162" class="alignnone size-full wp-image-724" /></a></p>
<p>The second problem I had was that a lot of the time the planes would be draw in such a way that their edge would be facing the camera, resulting in path that looked like it was missing pieces.</p>
<p>To get around this, I simple made it so that each segment of the smoke trail was always rotated to face the centre of the screen.  This resulted in smoke trails that tend to work from every position on the screen, except maybe in the dead centre.</p>
<p>Once I had a class set up to handle doing the smoke trails for the missiles, it was easy to port it to contrails on the wing tips, etc.</p>
<h2>Enemy Jets</h2>
<p>These are actually pretty boring.  They are basically just a bitmap texture applied to a plane that is position way off in the distance and scaled up to match the game speed.</p>
<p>Each of the jets actually use the same class, but have different constraints loaded in at run time via XML.  This meant that it was easy to debug because there was only one class, and I could also easily tweak the behaviours of each type of jet.</p>
<h2>Enemy bosses</h2>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/08/05/NightBoss.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/NightBoss-300x202.jpg" alt="" title="Strike Fighter NightBoss" width="300" height="202" class="alignright size-medium wp-image-680" /></a>The enemy bosses were like a a cross between the enemy jets and the players F35. </p>
<p>The jets themselves are some designs that the 3D guys and VJ modeled up.  Like the F35 they are loaded in as MD2 files at runtime. </p>
<p>Their behaviour is a bit like the enemy jets in that there is one common class for all of them, with each being given individual attributes via XML.</p>
<h2>Last little bits</h2>
<p>Once I had all of these elements built and tied together, I had to create a way to script what would happen when.  I came up with a simple xml structure that listed what type of enemy jets to spawn, how many to spawn at a time, when to save a checkpoint and when to fight a boss. </p>
<p>Then it was just a case of creating a manager class that parsed through this xml and triggered the correct items at the right time.</p>
<p>In the end this made it really easy to set up various stages and test out the different enemy units.</p>
<h2>Summary</h2>
<p>Strike Fighter was the first real serious game I had created in flash and I think it came together pretty nicely.  Of course I couldn&#8217;t have done it without the hard work from the team of guys at <a href="http://www.visualjazz.com.au">Visual Jazz</a> or the guys from wonderfl and Away3D.</p>
<p>If you have any question about anything I&#8217;ve mentioned here (or failed to mention) please feel free to drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/actionscript/strike-fighter-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strike Fighter</title>
		<link>http://www.sevenson.com.au/showcase/strike-fighter/</link>
		<comments>http://www.sevenson.com.au/showcase/strike-fighter/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 12:36:30 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Online Showcase]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Visual Jazz]]></category>

		<guid isPermaLink="false">http://www.sevenson.com.au/?p=685</guid>
		<description><![CDATA[Striker Fighter is an 80&#8242;s style arcade shooter that I built at Visual Jazz for the Defence Jobs Games website. It was really fun to build and really fun to play. At least, I think it is. I spent so long on it that it has become hard to tell It was actually completed months [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sevenson.com.au/content/uploads/2010/08/05/GameTile.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/GameTile-300x167.jpg" alt="" title="Strike Fighter Game Tile" width="300" height="167" class="alignright size-medium wp-image-676" /></a>Striker Fighter is an 80&#8242;s style arcade shooter that I built at <a href="http://visualjazz.com.au/#/portfolio/strike_fighter">Visual Jazz</a> for the <a href="http://games.defencejobs.gov.au/#/games/strikefighter">Defence Jobs Games</a> website.  It was really fun to build and really fun to play.  At least, I think it is.  I spent so long on it that it has become hard to tell <img src='http://www.sevenson.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It was actually completed months ago, I&#8217;ve just been lazy about adding it to my site.<br />
 <span id="more-685"></span><br />
<br clear="both"/><br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/TitleScreen.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/TitleScreen-300x202.jpg" alt="" title="Strike Fighter Title Screen" width="300" height="202" class="alignleft size-medium wp-image-682" /></a>The basis of the game is pretty standard &#8211; fight your way through wave after wave of enemy jets, and get as many points as you can. </p>
<p>To help keep things interesting there are two different styles of play &#8211; Campaign and Survival.<br />
<br clear="both"/></p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/08/05/DesertMissile.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/DesertMissile-300x202.jpg" alt="" title="Strike Fighter Desert Missile" width="300" height="202" class="alignright size-medium wp-image-674" /></a>The &#8216;Campaign&#8217; mode is set out in a stage by stage basis.<br />
There are 7 stages set across 5 different scenes, with each scene containing a different set of enemy aircraft that get progressively more difficult as the game goes on.<br />
At the end of each stage your score and bonuses are added up.  As you score more and more points you unlock new skins for your jet.<br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/LevelComplete.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/LevelComplete-300x202.jpg" alt="" title="Strike Fighter Campaign Level Complete" width="300" height="202" class="alignright size-medium wp-image-677" /></a><br />
You are also given the opportunity to spend the credits you collect on upgrades for your jet.  These are spread across three key areas &#8211; Armament, Avionics and Electronics &#8211; and include things like faster lock-on times, multiple missiles, radar jamming, agility upgrades, etc.<br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/Upgrades.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/Upgrades-300x202.jpg" alt="" title="Striker Fighter Upgrades Screen" width="300" height="202" class="alignright size-medium wp-image-683" /></a><br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/NightBoss.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/NightBoss-300x202.jpg" alt="" title="Strike Fighter NightBoss" width="300" height="202" class="alignright size-medium wp-image-680" /></a><br />
At the end of the last three areas you are confronted by extremely large &#8216;bosses&#8217; that almost fill the screen.  They attempt to ram you as well as bombard you with multiple missiles. Arghhh!<br />
<br clear="both"/><br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/SurvivalStages.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/SurvivalStages-300x202.jpg" alt="" title="Strike Fighter Survival Mode" width="300" height="202" class="alignleft size-medium wp-image-681" /></a>Survival mode is kinda the same except that instead of a &#8216;mission&#8217; based approach, you get just one life and fight through as many waves of enemy jets as you can. You also get to choose which scene the game will be set in, so you can practice with the various sky lines.<br />
<a href="http://www.sevenson.com.au/content/uploads/2010/08/05/GameOver.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/08/05/GameOver-300x202.jpg" alt="" title="Strike Fighter Game Over Screen" width="300" height="202" class="alignleft size-medium wp-image-675" /></a></p>
<p><br clear="both"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/showcase/strike-fighter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jay Jays Jayvatar Builder Goes Live</title>
		<link>http://www.sevenson.com.au/ramblings/jay-jays-jayvatar-builder-goes-live/</link>
		<comments>http://www.sevenson.com.au/ramblings/jay-jays-jayvatar-builder-goes-live/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 12:44:24 +0000</pubDate>
		<dc:creator>Andrew Sevenson</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<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=458</guid>
		<description><![CDATA[This week the Jay Jays Jayvatar Builder that Visual Jazz created went live. It&#8217;s a cool little tool that lets you create your own custom avatar for use on the Jay Jays site. Whith a very unique style and heaps of options you are sure to create some very cooky characters. This first release consists [...]]]></description>
			<content:encoded><![CDATA[<p>This week the <a href="http://www.jayjays.com.au" title="Check out the Jayvatar Builder on the Jay Jays site">Jay Jays</a> Jayvatar Builder that <a href="http://www.visualjazz.com.au" title="Check out the Visual Jazz site after you finish reading here">Visual Jazz</a> created went live.  It&#8217;s a cool little tool that lets you create your own custom avatar for use on the Jay Jays site.</p>
<p>Whith a very unique style and heaps of options you are sure to create some very cooky characters.</p>
<p><span id="more-458"></span></p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/02/26/Editor.png"><img src="http://www.sevenson.com.au/content/uploads/2010/02/26/Editor-300x211.png" alt="Screen shot of the Jayvatars Editor Page" title="Jayvatars Editor Page" width="300" height="211" class="alignleft size-medium wp-image-459" /></a>This first release consists mostly of the Jayvatar builder, which is where you can create your custom jayvatar by combining any of the various pieces of clothing and accessories.  You can also choose between male and female body types, as well as different attributes, such as height, weight and arm length.  </p>
<p>There is even a &#8216;random&#8217; button for the less visually creative that generates a random jayvatar automatically.</p>
<p>Once you have completed creating you Jayvatar, you can save it and share it via facebook, twitter and email.  You can also save a version onto your computer for whatever reason you have in mind.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/02/26/Playground.png"><img src="http://www.sevenson.com.au/content/uploads/2010/02/26/Playground-300x212.png" alt="Screenshot of the Beta Jayvatars Playground" title="Jayvatars Playground" width="300" height="212" class="alignleft size-medium wp-image-462" /></a>You can also play around with your Jayvatar in the Javatar Playground.<br/> Here you can make your Jayvatarcan fly around the screen, bump items, crash down, etc.</p>
<p>At the moment the playground is just a Beta version so there is only a limited amount of interactivity happening.  There full release will allow you to do a lot more.</p>
<p><a href="http://www.sevenson.com.au/content/uploads/2010/02/Jayvatars.jpg"><img src="http://www.sevenson.com.au/content/uploads/2010/02/Jayvatars.jpg" alt="Some random javatars" title="Jayvatars" width="600" height="277" class="alignnone size-full wp-image-479" /></a></p>
<p>As a bonus, those people from Australia and New Zealand that sign up soon will be given a free $10 voucher to spend in store&#8230; BONUS! </p>
<p>So what are you waiting for?  Head over to the <a href="http://www.jayjays.com.au" title="Check out the Jayvatar Builder on the Jay Jays site">Jay Jays</a> site and create your own..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sevenson.com.au/ramblings/jay-jays-jayvatar-builder-goes-live/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

