<?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>Daniel Groves Web Design</title>
	<atom:link href="http://danielgroves.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielgroves.net</link>
	<description></description>
	<lastBuildDate>Sat, 28 Jan 2012 16:45:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AFP Goodness between OS X Lion and Ubuntu 11.10</title>
		<link>http://danielgroves.net/2012/01/afp-goodness-between-os-x-lion-and-ubuntu-11-10/</link>
		<comments>http://danielgroves.net/2012/01/afp-goodness-between-os-x-lion-and-ubuntu-11-10/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 23:33:11 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[11.10]]></category>
		<category><![CDATA[afp]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[netatalk]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://danielgroves.net/?p=616</guid>
		<description><![CDATA[I&#8217;ve been working on assembling a private media and backup server for use with my Mac. In order to do this I needed to have AFP working between OS X and Ubuntu, as this is the protocol required by Time Machine for network backup servers. In order to set everything...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on assembling a private media and backup server for use with my Mac.  In order to do this I needed to have AFP working between OS X and Ubuntu, as this is the protocol required by Time Machine for network backup servers.<br />
<span id="more-616"></span></p>
<p>In order to set everything up I was <a href="http://www.kremalicious.com/2008/06/ubuntu-as-mac-file-server-and-time-machine-volume/" title="Make Ubuntu A Perfect Mac File Server And Time Machine Volume " target="_blank">following a guide</a> by <a href="http://www.kremalicious.com/" title="Matthias Kretschmann" target="_blank">Matthias Kretschmann</a>.  This guide seemed like the complete package, accept Apple have changed a few things in the AFP package in OS X for Lion.  The result of these changes is that everything breaks for Lion, but after a little doffing around the net I appear to have a working fix.  </p>
<p>This first error I encountered was &#8220;The version of the server you are trying to connect to is not supported&#8221;.  I quick bit of digging around revealed that the login protocol has been changed, but there is a quick fix for this.  The login protocol used before was DHX, and the new is DHX2.  So, in order to fix this we simply need to edit the afpd.conf file, to do this run the following command in your Ubuntu Terminal.  </p>
<pre>
sudo nano /etc/netatalk/afpd.conf
</pre>
<p>In order to fix the issue you now need to find your uncommented line for configuring the system, mine was at the bottom of the file and read as follows. </p>
<pre>
- -transall -uamlist uams_randnum.so,uams_dhx.so -nosavepassword -advertise_ssh
</pre>
<p>The issue is easily fixed by changing this line so that it is as follows (note the change in bold): </p>
<pre>
- -transall -uamlist uams_randnum.so,<strong>uams_dhx2.so</strong> -nosavepassword -advertise_ssh
</pre>
<p>So, whatever your configuration line reads I imaging as long as you change the bit that reads <tt>uams_dhx.so</tt> to <tt>uams_dhx2.so</tt> it should work.</p>
<p>Now just restart the service (see terminal command below) and get ready for the second error.</p>
<pre>
sudo /etc/init.d/netatalk restart
</pre>
<p>The second error was encountered after I connected to the server, so go ahead a connect (use your ubuntu login as a username and password), and wait.  After a second or two this error should appear:</p>
<figure id="attachment_627" class="aligncenter" aria-describedby="figcaption_attachment_627" style="width: 534px"><img src="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/Screen-Shot-2012-01-19-at-22.25.09.png" alt="Server Error" title="Server Error" width="534" height="275" class="size-full wp-image-627" /><figcaption id="figcaption_attachment_627">Server Error, where my server is called &quot;mserv1&quot;</figcaption></figure>
<p>This is also a quick fix, although the answer resides in a different file.  It turns out the the value that the guide tells us to use for <tt>cnidscheme</tt> is actually invalid, and so the server sends us this message every time we interact with it.  In order to get around this we need to change this to a valid value.  </p>
<p>Firstly, open the AppleVolumes.default file as follows: </p>
<pre>
sudo nano /etc/netatalk/AppleVolumes.default
</pre>
<p>Now look find one of your network volume configuration lines, foe example i have this one which means that I can log in and access my user directory.  </p>
<pre>
~/ "$u" allow:danielgroves cnidscheme:cdb
</pre>
<p>The part reading <tt>cnidscheme:cdb</tt> is what is causing the error, so we change this to <tt>cnidscheme:dbd</tt> to fix the error, meaning the line would now read like this:</p>
<pre>
~/ "$u" allow:danielgroves cnidscheme:dbd
</pre>
<p>Once you have made this change to each directory configuration that requires it, simple save you changes and restart the services. </p>
<pre>
sudo /etc/init.d/netatalk restart
sudo /etc/init.d/avahi-daemon restart
</pre>
<p>With a bit of luck, this post will help you to get round the issues that I have had.  If you hit any issues at all <a href="http://danielgroves.net/contact/" title="Contact">drop me a line</a> and I&#8217;ll try to help as far as I can.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2012/01/afp-goodness-between-os-x-lion-and-ubuntu-11-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mockups for danielgroves.net</title>
		<link>http://danielgroves.net/2012/01/mockups-for-danielgroves-net/</link>
		<comments>http://danielgroves.net/2012/01/mockups-for-danielgroves-net/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 11:53:00 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[mockup]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://danielgroves.net/?p=608</guid>
		<description><![CDATA[A friend of mine is currently trying to improve his skills when designing UIs for the web, and asked to see the initial UI mockups that I created for this site. So, without further udo I have decided to publish the original images here for all to see. All of...]]></description>
			<content:encoded><![CDATA[<p>A friend of mine is currently trying to improve his skills when designing UIs for the web, and asked to see the initial UI mockups that I created for this site.  </p>
<p>So, without further udo I have decided to publish the original images here for all to see.  All of the these designs were completed in Adobe Fireworks CS5 for Mac.<br />
<span id="more-608"></span></p>
<figure id="attachment_611" class="aligncenter" aria-describedby="figcaption_attachment_611" style="width: 550px"><a href="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2.jpg"><img src="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2-550x483.jpg" alt="Initial Mockup" title="Initial Mockup" width="550" height="483" class="size-medium wp-image-611" /></a><figcaption id="figcaption_attachment_611">Initial Mockup</figcaption></figure>
<figure id="attachment_610" class="aligncenter" aria-describedby="figcaption_attachment_610" style="width: 550px"><a href="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2_withoutArrows.jpg"><img src="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2_withoutArrows-550x483.jpg" alt="Feedback suggested I should remove the arrows from the content scroller" title="Feedback suggested I should remove the arrows from the content scroller" width="550" height="483" class="size-medium wp-image-610" /></a><figcaption id="figcaption_attachment_610">Feedback suggested I should remove the arrows from the content scroller</figcaption></figure>
<figure id="attachment_609" class="aligncenter" aria-describedby="figcaption_attachment_609" style="width: 502px"><a href="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2_portfolioPage.jpg"><img src="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/portfolio_v3_v2_portfolioPage-502x550.jpg" alt="Portfolio Page" title="Portfolio Page" width="502" height="550" class="size-medium wp-image-609" /></a><figcaption id="figcaption_attachment_609">Portfolio Page</figcaption></figure>
<p>Those are the actual mockups I used when creating the homepage and the portfolio page.  The homepage designs were posted on <a href="http://forr.st/~Ngt" title="Forrst post for the designs" target="_blank">Forrst</a> for those who have an account.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2012/01/mockups-for-danielgroves-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Going Solid State</title>
		<link>http://danielgroves.net/2012/01/going-solid-state/</link>
		<comments>http://danielgroves.net/2012/01/going-solid-state/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 10:23:31 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[64gb]]></category>
		<category><![CDATA[adapter]]></category>
		<category><![CDATA[crucial]]></category>
		<category><![CDATA[drives]]></category>
		<category><![CDATA[dual]]></category>
		<category><![CDATA[hard]]></category>
		<category><![CDATA[m4]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[ssd]]></category>
		<category><![CDATA[superdrive]]></category>

		<guid isPermaLink="false">http://danielgroves.net/?p=586</guid>
		<description><![CDATA[I&#8217;ve been considering getting a solid state drive (or SSD) for a while. I have a 2008 MacBook with a 2.00GHz Core 2 Duo, 4GB of DDR3 ram and a 640GB hard drive. That last point is an important one, I have a 640GB drive upgrade for a reason, I...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been considering getting a <a href="http://en.wikipedia.org/wiki/Solid-state_drive" title="Solid State Drive" target="_blank">solid state drive</a> (or SSD) for a while.  I have a <a href="http://support.apple.com/kb/sp500" title="Late 2008 MacBook" target="_blank">2008 MacBook</a> with a 2.00GHz Core 2 Duo, 4GB of DDR3 ram and a 640GB hard drive.  That last point is an important one, I have a 640GB drive upgrade for a reason, I simply need to storage capacity. My MacBook is my primary computer and so I cannot afford to loose the storage capacity.<br />
<span id="more-586"></span></p>
<h3>The Solution</h3>
<p>To solve this issue I decided to loose my SuperDrive and to have dual hard drives in my MacBook instead.  This meant I would run an SSD as my primary drive, and my old 640GB optical drive as a secondary bay, sat where my SuperDrive once was. </p>
<p>The disadvantage of this, aside from the obvious sacrifice of my SuperDrive, is a small reduction in battery life as I am now running dual hard drives.  The advantage is of course the huge performance increase that comes with an SSD, as well as keeping the large amount of storage capacity I had before. </p>
<h3>The Hardware</h3>
<p>I decided that this had to be done on a budget.  I&#8217;m a student and so I don&#8217;t have loads of cash to blow.  I aimed to get everything I need for as close to the £100 mark as I could.  </p>
<p>The obvious starting point was to look for a suitable SSD.  I have a 2.5&#8243; hard drive bay with a SATA2 interface and space for a drive with a <strong>maximum</strong> depth of 9.5mm in the hard drive bay, this limited my option as some makes of drive such as the <a href="http://www.ocztechnology.com/products/solid_state_drives" title="OCZ SSDs" target="_blank">OCZ drives</a> are too deep.  </p>
<p>In the end I chose a <a href="http://www.crucial.com/uk/store/ssd.aspx?gclid=CJ6JipeX2K0CFeshtAodSBLwSA&#038;cpe=pd_google_uk&#038;ef_id=cwpPFgAX2VMAAESb:20120117231119:s" title="Crucial M4 SSD" target="_blank">Crucial M4 64GB SSD</a> as it seemed to fit the bill with the best price, performance and most importantly the 9.5mm depth I required for it to fit in my MacBook.  </p>
<p>After this I needed an adapter for my SuperDrive bay so that I could install the old hard drive in it&#8217;s place.  With this I decided to take a risk, I didn&#8217;t have the budget available to splash out on a main stream brand, so I went over to eBay to see what I could find.  I cam across a <a href="http://www.ebay.co.uk/itm/280778916307?ssPageName=STRK:MEWNX:IT&#038;_trksid=p3984.m1439.l2649#ht_855wt_986" title="SuperDrive adapter on eBay" target="_blank">9.5mm bay for £13.99</a>, which I purchased. </p>
<p>Finally I also ordered an <a href="http://www.ebay.co.uk/itm/320817808106?ssPageName=STRK:MEWNX:IT&#038;_trksid=p3984.m1439.l2649#ht_3160wt_1219" title="External DVD Drive on eBay" target="_blank">external DVD&plusmn;RW drive</a>.  I decided to do this as I didn&#8217;t want to completely sacrifice my capabilities to do such things as watching DVDs or copying CDs into iTunes, especially as I rely on my MacBook for everything.  It is my DVD player, it is my CD player. It&#8217;s even my TV.  </p>
<p>With the exception of the DVD drive everything has now arrived and been running for about a week.  I have had a few bugs to iron out, maybe I&#8217;ll look into those in a future post, but for now the biggest issue.  </p>
<h3>TRIM on a Mac</h3>
<p><a href="http://en.wikipedia.org/wiki/TRIM" title="TRIM on an SSD" target="_blank">TRIM</a> is vital have have running when using an SSD.  I won&#8217;t go into any depth about it here as it is easy enough to find information on it elsewhere on the internet. What I will do here is explain how to activate it on OS X and how to find out if it is working on OS X.  </p>
<p>All of this was completed on version OS 10.7.2 &#8220;Lion&#8221; with no problems, although I would suggest taking the usual precautions before messing with any system settings.  </p>
<p>TRIM will most likely not be activated on any Mac that does not have an apple supplied SSD under the hood, but it is easy to enable.  To check if it is enabled or not go to &#8220;&#63743; -> About This Mac -> More Info&#8230;&#8221;.  From here press system report and then select &#8220;Serial-ATA&#8221; in the sidebar.  If it is enabled it should look something like the image below. </p>
<figure id="attachment_598" class="aligncenter" aria-describedby="figcaption_attachment_598" style="width: 550px"><a href="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/trimOnOSX.png"><img src="http://d3mkqoxzooo4lq.cloudfront.net/wp-content/uploads/2012/01/trimOnOSX-550x425.png" alt="Checking if TRIM is activated on OS X Lion" title="Checking if TRIM is activated on OS X Lion" width="550" height="425" class="size-medium wp-image-598" /></a><figcaption id="figcaption_attachment_598">Checking if TRIM is activated on OS X Lion</figcaption></figure>
<p>To activate TRIM fire up a new Terminal window a use the following commands: </p>
<pre>
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches
</pre>
<p>Once you have run these commands simply reboot your Mac for it all to take effect. </p>
<p>Overall I don&#8217;t think any of the money spent was wasted.  For day to day tasks and launching software though this machine now feels tenfold faster.  I&#8217;ll publish some bench marking results in the next few days to show just how big an improvement the SSD has bought around.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2012/01/going-solid-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Bluetooth: Not Available&#8221;</title>
		<link>http://danielgroves.net/2012/01/bluetooth-not-available/</link>
		<comments>http://danielgroves.net/2012/01/bluetooth-not-available/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 20:52:28 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[avalible]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[PRAM]]></category>

		<guid isPermaLink="false">http://danielgroves.net/?p=571</guid>
		<description><![CDATA[It&#8217;s not very often that I get any issues at al with my MacBook, let alone an issue this bad. I can&#8217;t actually remember the last time I had a major issue, but given my MacBook is now well out of warranty the last thing I am going to do...]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not very often that I get any issues at al with my MacBook, let alone an issue this bad.  I can&#8217;t actually remember the last time I had a major issue, but given my MacBook is now well out of warranty the last thing I am going to do is take it near a Genius bar and risk having pay out loads of money I don&#8217;t have.</p>
<p>After a reboot earlier today it came as a surprise then when the bluetooth icon in the menubar as a zigzagged line through it, providing the following information when clicking on it &#8220;Bluetooth: Not Available&#8221;.  </p>
<p><span id="more-571"></span></p>
<p>During the reboot my system appeared to freeze, just before the login screen appeared so, after a while of waiting, I resulted to force it to reboot.  This time it booted fine, except for the bluetooth error.  </p>
<p>After a little Googling I found an <a href="http://bjhess.com/blog/mac_bluetooth_not_available_after_power_outage/" title="Mac bluetooth not available after power outage" target="_blank">article by Barry Hess</a> about a similar issue caused by a power cut. </p>
<p>Unfortunately for me his solution didn&#8217;t work, but I had an idea which, for now, appears to have worked. What I proceeded to do was to <a href="http://support.apple.com/kb/ht1379" title="Resetting the PRAM on your Mac" target="_blank">reset the PRAM</a> on my Mac.  To do this you simply reboot while holding &#8984; + &#8997; + P + R. Once you hear the chime of your Mac restarting the process is complete, you can simply release the keys to resume a normal start-up.  </p>
<p>I have published these finding here with the hope that someone will find them useful, or perhaps I may require them again one day in the future.  </p>
<div class="update">
<h3>Update 23/01/2012</h3>
<p>This issue occurred again today, and this time none of the steps outlined here would work in order to fix the issue.  After more research and trail and error exercises, I found that <a href="http://support.apple.com/kb/ht3964" title="Reset the SMC on an Intel Mac" target="_blank">resetting the SMC</a> in an intel based Mac is another common solution, and worked for me on this occasion.  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2012/01/bluetooth-not-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing Visualisation Development</title>
		<link>http://danielgroves.net/2011/04/processing-visualisation-development/</link>
		<comments>http://danielgroves.net/2011/04/processing-visualisation-development/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 11:44:35 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=365</guid>
		<description><![CDATA[The concept for the data visualisation that I have produced came from the idea of how I have always seen data being presented as a child. I took the principle of a simple bar graph and decided to show a history of several of the different pieces of information available...]]></description>
			<content:encoded><![CDATA[<p>The concept for the data visualisation that I have produced came from the idea of how I have always seen data being presented as a child.  I took the principle of a simple bar graph and decided to show a history of several of the different pieces of information available in the feeds.  Further, I decided to implement the current windspeed into the data, but in a unique way.   I decided that the bars should all drift from left to right at the current windspeed, in order to keep the data readable I also decided that the addition of a click event should be present to pause this animation.  </p>
<h3>Class File</h3>
<p>The development of the data visualisation took shape in several steps, the first of these was to develop a class file for the bars.  These objects are all pretty much the same, a rectangle.  The only ways they differentiate are in colour, height and the horizontal position.  </p>
<p>In order to minimise the amount of data having to be passed around, and so the amount of memory being used in turn I decided to access the data array directly from the class where needed.<br />
<span id="more-365"></span></p>
<p>I have added additional comments into the source code below to show exactly what is going on.  </p>
<pre>class Bar
{

  // Variable Declaration
  int from = 0;
  float barHeight = 0;
  int barWidth = 8;
  int growSpeed = 1;
  int barHorizPos;
  color barColor;

  // Constructor, updates variables local to class with those passed in
  Bar( float theHeight, color theColor, int theHorizPos )
  {
    barHeight = theHeight;
    barHorizPos = theHorizPos;
    barColor = theColor;
  }

  // Method that actually creates and animates the bar
  void display()
  {

    // What the rectangle will look like
    rectMode(CORNER);
    fill(barColor);
    stroke(0);

    // Work out if the bar is the right height, and shrink it if it's not.
    if (from == barHeight)
      rect(barHorizPos, (400 - barHeight), barWidth, barHeight);
    else if (from > barHeight)
    {
      from = from - growSpeed;
      rect(barHorizPos, (400 - from), barWidth, (from - growSpeed));
    }
    else if (from < barHeight)
    {
      from = from + growSpeed;
      rect(barHorizPos, (400 - from), barWidth, from);
    }

    // Detect is sideways movement is on or off and either move of leave accordingly
    if ( barMove)
    {

      barHorizPos = barHorizPos + int(xmlData[0][0]);
      if ( barHorizPos >= 300 )
        barHorizPos = -15;

    }

  }
}</pre>
<h3>Highest Value Function</h3>
<p>In order to map the bars correctly I need to establish the highest value from each of the feeds I need to stream.  In order to do this I wrote the following function which simply returns that highest number as a float.  </p>
<pre>int highestValue( int index )
{
  int number = 0;

  if ( int(xmlData[index][0]) > int(xmlData[index][1]) &#038;&#038; int(xmlData[index][0]) > int(xmlData[index][2]) )
    number = int(xmlData[index][0]);

  else if ( int(xmlData[index][1]) > int(xmlData[index][0]) &#038;&#038; int(xmlData[index][1]) > int(xmlData[index][2]))
    number = int(xmlData[index][1]);

  else if ( int(xmlData[index][2]) > int(xmlData[index][0]) &#038;&#038; int(xmlData[index][2]) > int(xmlData[index][1]))
    number = int(xmlData[index][2]);

  return number;
}</pre>
<h3>Bar Color Function</h3>
<p>I decided that the colour of each bar should change based on the current outside temperature.  In order to do this I decided to create a function that would generate the correct colour for each.  The function assigns a random amount of green, and uses the current temperature for the red and blue.  Finally the alpha is decreased over each bar to help show that some data is older than other pieces.  </p>
<pre>color barColor( int index)
{

  int redValue;
  int blueValue;

  int sumComponent = int(map( xmlData[2][0], 0, highestValue(2),0, 255));

  if (index == 1)
    return color(sumComponent, random(0,255), sumComponent, 200);
  else if(index == 2)
    return color(sumComponent, random(0,255), sumComponent, 255);
  else
    return color(sumComponent, random(0,255), sumComponent, 155);

}</pre>
<h3>Main Code Block</h3>
<p>Finally, the main block of code contains the click event, XML processing, object set-up and the draw and setup functions.  I ahve added additional comments to the source code below to explain it.  </p>
<pre>import processing.xml.*;

// The array contains all of the feeds that I decided to use
String[] feedLocations = {
  "http://x2.i-dat.org/archos/archive.rss?source=.WindSpeed",
  "http://x2.i-dat.org/archos/archive.rss?source=.OutAirHum",
  "http://x2.i-dat.org/archos/archive.rss?source=.OutAirTemp",
  "http://x2.i-dat.org/archos/archive.rss?source=.WindVane",
  "http://x2.i-dat.org/archos/archive.rss?source=.Elec_A_YDay",
  "http://x2.i-dat.org/archos/archive.rss?source=.LT3_AirHum",
};

// This array is for holding the data once it has been converted to floats
float[][] xmlData     = new float[7][3];

// Variable needs to be public so the class file can see it, controls the sideways animation
Boolean barMove = true;

// Object array for holding the bars
Bar[] bars = new Bar[18];

void setup()
{
  // Canvas setup
  size(300,400);
  frameRate(25);

  // For loop for processing the feeds and populating the xmlData array with floats
  for (int f = 0; f < 6; f++)
  {
    XMLElement xml = new XMLElement(this, feedLocations[f]);
    XMLElement[] xmlValue = xml.getChildren("channel/item/description");

    for ( int g = 0; g < 3; g++)
      xmlData[f][g] = float(xmlValue[g].getContent());
  }

  // Variables used in order to help generate the bars
  int arrayLocation = 0;
  int position = 10;

  // Two-tier for loop for generating the bars, works through both levels of the array methodically creating the bars
  for (int i = 1; i < 6; i++)
  {

    for (int j = 0; j < 3; j++)
    {
      bars[arrayLocation] = new Bar( int(map(xmlData[i][j], 0, highestValue(i), 0, 350)), barColor(j), position );
      arrayLocation++;
      position = position + 15;
    }

    position = position + 15;

  }

}

// Function for drawing the bars
void draw()
{
  // Clear the canvas every frame
  background(0);

  // And then redraw all the bars in their new location
  for(int i = 0; i < 15; i++)
      bars[i].display();
}

// Click event for stopping sideways animation
void mousePressed(MouseEvent e)
{
  if ( barMove )
    barMove = false;
  else
    barMove = true;
}
</pre>
<h3>Evaluation</h3>
<p>If I had more time to do this project again I would have added protocols to deal with things such as negative numbers, these currently generate a bar of 0 height, meaning that it appears to be a brocken bar.  I would also have optimised the actual code much more so that it doesn't use so much memory when running, an would also load faster.<br />
This project went well in that I successfully visualised the data, and added an interactive element to the project, much of the code is also automated meaning it would be relatively easy to add more bars or change the data that is being streamed.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/04/processing-visualisation-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash game: Evaluation</title>
		<link>http://danielgroves.net/2011/02/flash-game-evaluation/</link>
		<comments>http://danielgroves.net/2011/02/flash-game-evaluation/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 21:01:33 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[WADgame]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=364</guid>
		<description><![CDATA[Making a game in flash isn&#8217;t easy. It takes a lot of time, especially if you are writing your first. During this process I think their are plenty of things I could have done differently,or better, but these are some of the most importent that i feel I should consider...]]></description>
			<content:encoded><![CDATA[<p>Making a game in flash isn&#8217;t easy.  It takes a lot of time, especially if you are writing your first.  </p>
<p>During this process I think their are plenty of things I could have done differently,or better, but these are some of the most importent that i feel I should consider next time.  </p>
<ol>
<li>Better Planning: In the future I think I should plan how I am going to implement my game better.  I should create all necessary graphics and movie clips before I start coding, and then I should write out basic functions and event listeners before filling them in order to ensure Iw rite the most efficient code possible.  </li>
<li>Debugging: In the future I should schedule more de-bugging time so this is not such as rushed process</li>
<li>Software Versions: At the start of this assignment it was not made clear that the game must be submitted in CS4 fortmat, over CS5.  In the future I will ensure that it is as clear as possible as to which version I am expected to work with.  The result of converting my work from the CS4 to the CS5 format was simply that I ended with 6-7 errors, oh which two were particularly difficult to solve.  </li>
<li>Improved UI: If I was to go through this process again I would spend time designing features such as the UI in order to make them more intuitive and easier for the user to use.
</ol>
<p>These listed things that I would do better in the future could most definitely be extended, to things such as building my oen classes to optimise code, but I feel these are the most importent changes that I would make if I was to come back and do this project again in the future.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/02/flash-game-evaluation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Game: Backend Processing</title>
		<link>http://danielgroves.net/2011/02/flash-game-backend-processing/</link>
		<comments>http://danielgroves.net/2011/02/flash-game-backend-processing/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 20:49:34 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[WADgame]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=361</guid>
		<description><![CDATA[In order to set-up a high-score system I need a database and some backend processing scripts, written in PHP. The first thing I did was to set-up a database with the appropriate fields: ID, Name and Score. I then used the following PHP script in order to write scores to...]]></description>
			<content:encoded><![CDATA[<p>In order to set-up a high-score system I need a database and some backend processing scripts, written in PHP.  </p>
<p>The first thing I did was to set-up a database with the appropriate fields: ID, Name and Score.</p>
<figure id="attachment_362" class="aligncenter" aria-describedby="figcaption_attachment_362" style="width: 550px"><img src="http://daniel-groves.co.uk/wordpress/wp-content/uploads/2011/02/Screen-shot-2011-02-04-at-20.36.00-550x403.png" alt="Database in phpMyAdmin" title="Database in phpMyAdmin" width="550" height="403" class="size-large wp-image-362" /><figcaption id="figcaption_attachment_362">Database in phpMyAdmin</figcaption></figure>
<p>I then used the following PHP script in order to write scores to the database (database information has been removed for security purposes.  </p>
<p><span id="more-361"></span></p>
<pre>////////////////// modify this information ///////////////////////
$host = "localhost"; //hostname is usually localhost by default
$user = ""; //insert the name of the user here
$pass = "";  //insert the password here
$database = "";  //insert name of database wherein table was exported
$table = "";  //insert the name of the table
///////////////////////////////////////////////////////////////////////

//stores the URLvariables into variables that php can use
$one = $_POST['yourname'];
$five = $_POST['yourscore'];

echo($one);
echo($five);

  // Connects to the database server
  $dbcnx = @mysql_connect($host, $user, $pass);
  if (!$dbcnx) {
    echo( "&lt;p&gt;Unable to connect to the database server at this time.&lt;/p&gt;" );
    exit();
  }

  // Selects the database
  if (! @mysql_select_db($database) ) {
    echo( "&lt;p&gt;Unable to find database&lt;/p&gt;");
    exit();
  }

//this is the command used to write the record into the MySQL database
$query="INSERT into {$table} (name, score) VALUES ('{$one}',{$five})";   

//executes the command
mysql_query($query) or die("Data not written.");
echo("The data has been written to the table!");
?></pre>
<p>This script simply takes the score and username, which are passed to it via the <tt>POST</tt> method and writes them to the database.  </p>
<p>This second script then reads the top five results, orders them, and renders them ready to be read by action script.  For unknown reasons this PHP will not embed properly in this page, and has therefore been <a href="http://daniel-groves.co.uk/wordpress/wp-content/uploads/2011/02/circuitRacerHighScores.txt" target="_blank">provided to view in a text document</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/02/flash-game-backend-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Game: High Scores Page</title>
		<link>http://danielgroves.net/2011/02/flash-game-high-scores-page/</link>
		<comments>http://danielgroves.net/2011/02/flash-game-high-scores-page/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 20:07:44 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[WADgame]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=360</guid>
		<description><![CDATA[This post looks at exactly how I extracted the high-scores form the database via PHP script. import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; This first section loads the nessesery class files. stop(); Followed by the stop function to stop the flash file moving back to frame one. backToMenu.addEventListener(MouseEvent.CLICK, menuLoad); This line...]]></description>
			<content:encoded><![CDATA[<p>This post looks at exactly how I extracted the high-scores form the database via PHP script.  </p>
<pre>import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;</pre>
<p>This first section loads the nessesery class files.  </p>
<pre>stop();</pre>
<p>Followed by the <tt>stop</tt> function to stop the flash file moving back to frame one.  </p>
<p><span id="more-360"></span></p>
<pre>backToMenu.addEventListener(MouseEvent.CLICK, menuLoad);</pre>
<p>This line listens for a click event on the back to main menu button and then activates thr function <tt>menuLoad</tt> which takes the user back to the nenu on frame one.  </p>
<pre>function textLoadComplete(event:Event):void
{
        txtBox.htmlText = textLoader.data;
		trace(textLoader.data);
}</pre>
<p>This function is called by the event listener (below) in order to display the high-scores which are loaded from a server-side PHP script.  </p>
<pre>var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest("http://files.danielgroves.net/circuitRacerScores.php");

textLoader.load(textReq);
textLoader.addEventListener(Event.COMPLETE, textLoadComplete);</pre>
<p>This is the section of action script that fetches the PHP files that fetches the high scores, and then returns the results to the document.  </p>
<pre>function menuLoad(event:Event):void
{

	gotoAndStop(1);

}</pre>
<p>The final function that takes the user back to the main menu when activated.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/02/flash-game-high-scores-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Game: The Game</title>
		<link>http://danielgroves.net/2011/02/flash-game-the-game/</link>
		<comments>http://danielgroves.net/2011/02/flash-game-the-game/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 19:19:22 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[WADgame]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=359</guid>
		<description><![CDATA[This blog post explains the ActionScript in frame two. Frame two was where the game itself existed, along with the ending screen which shows the user the score they achieved as well as giving them the option to submit it to the high scores tables. import flash.events.Event; import flash.utils.Timer; import...]]></description>
			<content:encoded><![CDATA[<p>This blog post explains the ActionScript in frame two.  Frame two was where the game itself existed, along with the ending screen which shows the user the score they achieved as well as giving them the option to submit it to the high scores tables.  </p>
<pre>import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;

import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
</pre>
<p>This first block of code imports the necessary class files for the actions script on this frame.  </p>
<pre>stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, userCarControler);
stage.addEventListener(Event.ENTER_FRAME, computerCarControler);
stage.addEventListener(Event.ENTER_FRAME, userWins);
submitScore.addEventListener(MouseEvent.CLICK, scoreSubmited);
mainMenuLink.addEventListener(MouseEvent.CLICK, mainMneu);</pre>
<p><span id="more-359"></span></p>
<p>This second block of code listens for the necessary events, such as activating functions on every frame refresh or detecting menu item clicks.  </p>
<pre>var raceTimer:Timer=new Timer(1000,0);
raceTimer.addEventListener(TimerEvent.TIMER, stopWatch);
raceTimer.start();
var raceTimerValue:Number = 0;
function stopWatch(event:TimerEvent):void
{
	raceTimerValue++;
	txtTimer.text = raceTimerValue + " Seconds";
}</pre>
<p>This block of code times the race so that the user can be scored based on how quickly they complete the laps.  </p>
<pre>var computerCarSpeed:Number = 6;</pre>
<p>This line sets the speed which the computer car can move at.  This variable means I can stop the computer car from being able to move when the user wins the game.</p>
<pre>var userCar_up:Boolean = false
var userCar_down:Boolean = false
var userCar_left:Boolean = false
var userCar_right:Boolean = false</pre>
<p>In order to achieve the smooth movement of the users car I create four variables.  Each of these booleans is activated on holding the corresponding arrow key down, and then deactivates on releasing the key.  This menas that the animation is either on or off, rather than turning on and off quickly and so smooth animation is achieved.  </p>
<pre>var userCarHits:Number = 0;
var userCompleteLaps:Number = 0;
var userNoCheat:Number = 0;
var finalScore:Number = 0;</pre>
<p>These are variables that need to be accessible by all functions.  These are used for logging the number of times the user has hit the CPU car, to detect is the user is cheating or not by not going all the way around the track, and to store the score that the user achieves.  </p>
<pre>userName.visible = false;
nameBackground.visible = false;
nameLabel.visible = false;
yourScore.visible = false;
submitScore.visible = false;
mainMenuLink.visible = false;
gameTitle.visible = false;
mcGameEndBg.visible = false;</pre>
<p>This small block of code is used to hide all of the instances of objects that are required to inform the user that they have finished the game and allow them to submit their high score and navigate away from the high-score page.  </p>
<pre>function keyDownHandler(e:KeyboardEvent):void
{
	// Detect if "up" arrow is held down
	if(e.keyCode == 38)
	{
		userCar_up = true;
	}

	// Detect if "down" arrow is held down
	if(e.keyCode == 40)
	{
		userCar_down = true;
	}

	// Detect if "right" arrow is held down
	if(e.keyCode == 39)
	{
		userCar_right = true;
	}

	// Detect if "left" arrow is held down
	if(e.keyCode == 37)
	{
		userCar_left = true;
	}
}</pre>
<p>This section of called via any key being pressed on the keyboard. When the key is held down, it sets the arrow keys corresponding <tt>boolean</tt> to <tt>true</tt>.  </p>
<pre>function keyUpHandler (e:KeyboardEvent):void
{

	// Detect if "up" arrow has been released
	if(e.keyCode == 38)
	{
		userCar_up = false;
	}

	// Detect if "down" arrow has been released
	if(e.keyCode == 40)
	{
		userCar_down = false;
	}

	// Detect if "right" arrow has been released
	if(e.keyCode == 39)
	{
		userCar_right = false;
	}

	// Detect if "left" arrow has been released
	if(e.keyCode == 37)
	{
		userCar_left = false;
	}

}</pre>
<p>This function sets the booleans that contorl which way the car moves gto false once the user releases the corresponding arrow key.  </p>
<pre>function userCarControler(event:Event)
{

	if (userCar.hitTestPoint(computerCar.x, computerCar.y))
	{
		userCarHits = userCarHits + 1;
	}

    if (grass1.hitTestObject(userCar) || grass2.hitTestObject(userCar))
	{
		userCar.x = 171.2;
		userCar.y = 365.55;

		trace("hit grass");

	}

	var carSpeed:Number = 7;

	if(userCar_up)
	{
		userCar.rotation = 270;
		userCar.y -= carSpeed;
	}

	if(userCar_down)
	{
		userCar.rotation = 90;
		userCar.y += carSpeed;
	}

	if(userCar_right)
	{
		userCar.rotation = 0;
		userCar.x += carSpeed;
	}

	if(userCar_left)
	{
		userCar.rotation = 180;
		userCar.x -= carSpeed;
	}

	if (mcMk5.hitTestObject(userCar))
	{
		userNoCheat++;
	}

	if (userNoCheat > 0 &#038;&#038; userCar.hitTestObject(mcStartLine))
	{

		userCompleteLaps++;
		userNoCheat = 0;

	}

	txtLap.text = String(userCompleteLaps) + "/5 Laps";
}</pre>
<p>This function is run on entering the frame.  As a result it continually can adapter what the users car can do and when.  </p>
<p>The first <tt>if</tt> statement is used to detect if the suers car has hit the computers car.  When it hits the computers car it adds one on the varible <tt>userCarHits</tt> so that the ActionScript can keep a record of how many times the user car has hit the comuters car.  This si used for the scoring later on.  </p>
<p>The next if statement is used to detect if the user is cheating by trying to drive accross the grass. If the user does try to drive across the grass their car is automaticly be reset back to the start line as a punishment for attempting to cheat. To do this I used the <tt>userCar.x</tt> and <tt>userCar.y</tt> properties.  </p>
<p>The next varible declared is <tt>carSpeed</tt>. This is used to set the speed at which the user car can move.  </p>
<p>After this there are another four <tt>if</tt> statements.  These <tt>if</tt> statements are used in order to detects which way the users car is meant to be going, based on weather the previously discussed <tt>booleans</tt> are <tt>true</tt> or <tt>false</tt>, and then set the car speed accordingly.  </p>
<p>The second to last <tt>if</tt> statement then records if the users car has reached the checkpoint part way round the circuit, in order to establish if they are completeing the track or just going back and forth over the start line.  </p>
<p>The final <tt>if</tt> statement will then detect if the user has gone all the way around the track, going over the checkpoint, or if the user has simple gone back and forht over the start line.  The lap then gets logged if it was genuine.  </p>
<pre>function computerCarControler(event:Event)
{

	var direction:String = "";

	if (mcMk1.hitTestObject(computerCar))
	{
		direction = "right";
	}
	else if (mcMk2.hitTestObject(computerCar))
	{
		direction = "up";
	}
	else if (mcMk3.hitTestObject(computerCar))
	{
		direction = "left";
	}
	else if (mcMk4.hitTestObject(computerCar))
	{
		direction = "up";
	}
	else if (mcMk5.hitTestObject(computerCar))
	{
		direction = "left";
	}
	else if (mcMk6.hitTestObject(computerCar))
	{
		direction = "down";
	}

	if (direction == "right")
	{

		computerCar.x += computerCarSpeed;
		computerCar.y += 0;
		computerCar.rotation = 0;

	}
	else if (direction == "up")
	{

		computerCar.x += 0;
		computerCar.y -= computerCarSpeed;
		computerCar.rotation = 270;

	}
	else if (direction == "left")
	{

		computerCar.x -= computerCarSpeed;
		computerCar.y += 0;
		computerCar.rotation = 180;

	}
	else if (direction == "down")
	{

		computerCar.x += 0;
		computerCar.y += computerCarSpeed;
		computerCar.rotation = 90;

	}

}</pre>
<p>This function is used in order to contorl the CPU based car.  The direction of the car is determin based on what area of the track the car is on, which is established by running <tt>.hitTestObject</tt> on the computers car and the different areas of the track.  </p>
<p>Once this has been established the varible <tt>direction</tt> is set and then the the following <tt>if</tt> statement set the car in the right direction and rotate it to face in the correct direction.  </p>
<pre>function userWins(event:Event):void
{

	if (userCompleteLaps == 5)
	{
		raceTimer.stop();

		finalScore = raceTimerValue + (userCarHits * 5);

		yourScore.text = "You Scored: " + finalScore;

		userName.visible = true;
		nameBackground.visible = true;
		nameLabel.visible = true;
		yourScore.visible = true;
		submitScore.visible = true;
		mainMenuLink.visible = true;
		gameTitle.visible = true;
		mcGameEndBg.visible = true;

	}

}</pre>
<p>Once the user has completed five laps, this function takes over.  It stop the timer and then calculates the final score by taking the timer value and then adding on the amount of times the computer car has been hit and multiplys it by five.  This score is then displayed.  </p>
<p>This is followed by the the selecting of all the instances that make up the post-game screen and setting the property <tt>.visible</tt> to <tt>true</tt> which means that they can show over the top of the other content.  </p>
<pre>function scoreSubmited(event:Event):void
{
	var phpVars:URLVariables = new URLVariables();
	var phpFileRequest:URLRequest = new URLRequest("http://files.danielgroves.net/circuitRacerWrite.php");
	phpFileRequest.method = URLRequestMethod.POST
	phpFileRequest.data = phpVars;

	var phpLoader:URLLoader = new URLLoader();
	phpLoader.dataFormat = URLLoaderDataFormat.TEXT;

	phpVars.yourname = userName.text;
	phpVars.yourscore = finalScore;

	phpLoader.load(phpFileRequest);
}</pre>
<p>This function is called when the user clicks the button to submit their score.  It then send the score and the users name to and external PHP script to be processed and added to the MySQL database.  </p>
<pre>function mainMneu(event:Event):void
{
	trace("gotoframe1");

	userName.visible = false;
	nameBackground.visible = false;
	nameLabel.visible = false;
	yourScore.visible = false;
	submitScore.visible = false;
	mainMenuLink.visible = false;
	gameTitle.visible = false;
	mcGameEndBg.visible = false;

	// Reset car locations
	userCar.x = 171.2;
	userCar.y = 364.55;
	computerCar.x = 171.2;
	computerCar.y = 338.55;
	computerCarSpeed = 0;

	gotoAndStop(1);

}</pre>
<p>This final function is triggered when the user clicks the button to go back to the main menu.  This hides all of the non-game elements again, resets and the coputer and users car locations and stop the computer car from moving.  It then take the user back to frame one where the main menu is.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/02/flash-game-the-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash game: Main Menu</title>
		<link>http://danielgroves.net/2011/02/flash-game-main-menu/</link>
		<comments>http://danielgroves.net/2011/02/flash-game-main-menu/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 15:12:17 +0000</pubDate>
		<dc:creator>Daniel Groves</dc:creator>
				<category><![CDATA[WAD]]></category>
		<category><![CDATA[WADgame]]></category>

		<guid isPermaLink="false">http://daniel-groves.co.uk/?p=358</guid>
		<description><![CDATA[The main menu is one of the more important parts of a game. It gives you a method through which you can navigate the game and provide the user with instructions. Below I have worked through the AS3 from the first frame, explaining it line by line stop(); This first...]]></description>
			<content:encoded><![CDATA[<p>The main menu is one of the more important parts of a game.  It gives you a method through which you can navigate the game and provide the user with instructions.  </p>
<p>Below I have worked through the AS3 from the first frame, explaining it line by line</p>
<pre>stop(); </pre>
<p>This first line simply stop the animation from moving on to frame two, meaning the the menu stays on screen and the following ActonScript can be run at the appropriate moments.  </p>
<pre>import flash.events.MouseEvent; </pre>
<p>This second line of action script now imports the <tt>MouseEvent</tt> class files so that I can call the events in order to detect what the suer is doing with his or her mouse.  </p>
<p><span id="more-358"></span></p>
<pre>playGame.addEventListener(MouseEvent.CLICK, playGameLink);
playGame.addEventListener(MouseEvent.MOUSE_OVER, playGameOver);
playGame.addEventListener(MouseEvent.MOUSE_OUT, playGameOut);
highScores.addEventListener(MouseEvent.CLICK, highScoresLink);</pre>
<p>This block of code simply add event listeners which listen to each of the buttons and activates their corresponding function.  This provides click listeners in order to change onto the right frame for other parts of the game and mouse over/out listeners for sound.</p>
<pre>var carStart:Sound = new Sound();
carStart.load(new URLRequest("carStart.mp3"));
var carStartChannel:SoundChannel = new SoundChannel();

function playGameOver(event:MouseEvent):void
{
	carStartChannel = carStart.play();
}

function playGameOut(event:MouseEvent):void
{
	carStartChannel.stop();
}</pre>
<p>This block of code actives the sound.  When the user hovers the mouse of the &#8220;play&#8221; button it will activate a sound effect to make them aware that they are about to enter the game.  When the mouse is no longer over this button the sound is stopped.  </p>
<pre>function playGameLink(event:MouseEvent):void
{
	gotoAndStop(2); // go to frame 2 where the game is
}

function highScoresLink(event:MouseEvent):void
{
	gotoAndStop(4);  // go to frame 4 where the high scores are shown
}</pre>
<p>These final two lines of make the buttons change the frame.  One taking the user to the game itself, and the other to the High Scores.  </p>
]]></content:encoded>
			<wfw:commentRss>http://danielgroves.net/2011/02/flash-game-main-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 592/716 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d3mkqoxzooo4lq.cloudfront.net

Served from: danielgroves.net @ 2012-02-06 06:09:35 -->
