<?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>joshshard.com</title>
	<atom:link href="http://joshshard.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://joshshard.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 24 Feb 2010 16:13:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Layering + Better Hit Test</title>
		<link>http://joshshard.com/blog/?p=67</link>
		<comments>http://joshshard.com/blog/?p=67#comments</comments>
		<pubDate>Wed, 24 Feb 2010 16:13:36 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=67</guid>
		<description><![CDATA[Been quite busy recently not had much time to devote to blog and the game I have been working on. So I&#8217;ve had a free afternoon so put in a little time into the game and sorted out the layering of a single zombie with Bob. Looking pretty good, or at least I think, the [...]]]></description>
			<content:encoded><![CDATA[<p>Been quite busy recently not had much time to devote to blog and the game I have been working on. So I&#8217;ve had a free afternoon so put in a little time into the game and sorted out the layering of a single zombie with Bob. Looking pretty good, or at least I think, the next things I have to do is: Zombie Punch, Multiple Zombie with Layering, Scrolling Backgrounds, Sounds, then an intro menu. Doesn&#8217;t sound a lot but I reckon will take a while still.</p>
<p><object width="384" height="288" data="http://joshshard.com/jjgame/TestV5.swf" type="application/x-shockwave-flash"><param name="Layering + Better Hit Test" value="http://joshshard.com/jjgame/TestV5.swf" /><param name="src" value="http://joshshard.com/jjgame/TestV5.swf" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=67</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character Prototype.</title>
		<link>http://joshshard.com/blog/?p=56</link>
		<comments>http://joshshard.com/blog/?p=56#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:48:23 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=56</guid>
		<description><![CDATA[ So Jordan finished his animations and sent them over, been putting them into our game it&#8217;s still early but you can get a feel for the gameplay. You move around the stage with the arrows and punch with A and kick with S. Also introduced a walk animation and an idle animation. The characters [...]]]></description>
			<content:encoded><![CDATA[<p> So Jordan finished his animations and sent them over, been putting them into our game it&#8217;s still early but you can get a feel for the gameplay. You move around the stage with the arrows and punch with A and kick with S. Also introduced a walk animation and an idle animation. The characters coming together really nicely, we will be adding environments and enemies soon. I aim to get some done friday but I&#8217;m out thursday night so don&#8217;t know how I will be feeling. We just want a first level prototype up as soon as possible then we will start adding in more levels and a few little surprises.</p>
<p><object width="384" height="288" data="http://joshshard.com/jjgame/TestV2.swf" type="application/x-shockwave-flash"><param name="Character Prototype" value="http://joshshard.com/jjgame/TestV2.swf" /><param name="src" value="http://joshshard.com/jjgame/TestV2.swf" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=56</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow Fall</title>
		<link>http://joshshard.com/blog/?p=48</link>
		<comments>http://joshshard.com/blog/?p=48#comments</comments>
		<pubDate>Mon, 07 Dec 2009 00:30:54 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Motion Tracking]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=48</guid>
		<description><![CDATA[This application generates snowflakes that as they fall lay to rest on surfaces. It uses a webcam to track the user and a simple particle system for the snowflakes. It has all been done in Actionscript 3 and is using 2 classes that I have wrote. As mentioned in an earlier post I had seen [...]]]></description>
			<content:encoded><![CDATA[<p>This application generates snowflakes that as they fall lay to rest on surfaces. It uses a webcam to track the user and a simple particle system for the snowflakes. It has all been done in Actionscript 3 and is using 2 classes that I have wrote. As mentioned in an earlier post I had seen an AS2 version done by Grant Skinner, I decided to remake it in AS3 for a variety of reasons, one of the main reason was so that I knew how it all worked and I could alter things with more ease as I know my own coding habits.</p>
<p>The app is nearly done although I will be working on it over the next couple of weeks to make a better version, I aim to make it so the user is a silhouette. I will be trying it on tuesday where I will be rear projecting it onto a shop window and as passers by walk past the snow will fall on them. Video to come soon. But as for now I will leave you with the application.</p>
<p><object width="384" height="288" data="http://joshshard.com/blogResources/XmasSnow2.swf" type="application/x-shockwave-flash"><param name="Motion Tracking with Edge Finder" value="http://joshshard.com/blogResources/XmasSnow2.swf" /><param name="src" value="http://joshshard.com/blogResources/XmasSnow2.swf" /></object></p>
<p>I will also include this other small application which is where I am up to silhouetting the user, there are a lot of problems that I can see that I would like to iron out before implementing it with the snowfall but hopefully I can iron this out over the next week or so. To start it running just click on the stage with you out of camera view when you come back it will silhouette you.</p>
<p><object width="384" height="288" data="http://joshshard.com/blogResources/test1.swf" type="application/x-shockwave-flash"><param name="Flash Silhouette" value="http://joshshard.com/blogResources/test1.swf" /><param name="src" value="http://joshshard.com/blogResources/test1.swf" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=48</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edge Tracking with Hit Test</title>
		<link>http://joshshard.com/blog/?p=46</link>
		<comments>http://joshshard.com/blog/?p=46#comments</comments>
		<pubDate>Sun, 06 Dec 2009 16:36:36 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Motion Tracking]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=46</guid>
		<description><![CDATA[So this is a continuation of my last post, if you missed the last post I used a set of filters on a webcam to pick up the images so that I could then make snow settle on it, this is my first flake settling on the edge you can see it working as long [...]]]></description>
			<content:encoded><![CDATA[<p>So this is a continuation of my last post, if you missed the last post I used a set of filters on a webcam to pick up the images so that I could then make snow settle on it, this is my first flake settling on the edge you can see it working as long as there is an edge that stands out in the previous posts .swf it should settle on it, it&#8217;s just my first test and there are a few bugs to iron out but it works as an example and shows I&#8217;m on the right track.</p>
<p><object width="384" height="288" data="http://joshshard.com/blogResources/XmasSnow1.swf" type="application/x-shockwave-flash"><param name="Motion Tracking with Edge Finder" value="http://joshshard.com/blogResources/XmasSnow1.swf" /><param name="src" value="http://joshshard.com/blogResources/XmasSnow1.swf" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edge Tracking</title>
		<link>http://joshshard.com/blog/?p=40</link>
		<comments>http://joshshard.com/blog/?p=40#comments</comments>
		<pubDate>Fri, 04 Dec 2009 16:03:10 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Motion Tracking]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=40</guid>
		<description><![CDATA[Today I have been working on a motion tracker in AS3 that works on tracking the edges of the user this is so that I can create a snow fall effect that allows snow to settle around the user. I saw something similar to this done in AS2 when I was back at university by [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have been working on a motion tracker in AS3 that works on tracking the edges of the user this is so that I can create a snow fall effect that allows snow to settle around the user. I saw something similar to this done in AS2 when I was back at university by Grant Skinner. I&#8217;m trying to reproduce this in AS3, this is a project for a group of freelancers I work with known as The Interactivists. Basically we are creating something similar to what G Skinner used as an installation for a shop window.</p>
<p>So onto the code, I have started by bringing in a camera feed and applying filters to it until I have the edges highlighted in white the theory next is to basically dynamically make snowflakes which land on the generated surfaces and stay there until they are moved or disturbed.</p>
<p><object width="384" height="288" data="http://joshshard.com/blogResources/XmasSnow.swf" type="application/x-shockwave-flash"><param name="Motion Tracking with Edge Finder" value="http://joshshard.com/blogResources/XmasSnow.swf" /><param name="src" value="http://joshshard.com/blogResources/XmasSnow.swf" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zombies, Class Fun and Key Press Management.</title>
		<link>http://joshshard.com/blog/?p=36</link>
		<comments>http://joshshard.com/blog/?p=36#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:24:37 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://joshshard.com/blog/?p=36</guid>
		<description><![CDATA[ I recently have started work on a project with a friend. We will be building a side scrolling game. Jordan, will be concentrating on creating the visuals, everything from concept art to the final animations, while I will be focussing on programming.
So just a quick overview of the idea&#8230; We are going to build [...]]]></description>
			<content:encoded><![CDATA[<p> I recently have started work on a project with a friend. We will be building a side scrolling game. Jordan, will be concentrating on creating the visuals, everything from concept art to the final animations, while I will be focussing on programming.</p>
<p>So just a quick overview of the idea&#8230; We are going to build a side scrolling game, that involves everyone&#8217;s favourite enemy&#8230; ZOMBIES!!! We are aiming to have a rough prototype by december without character&#8230; named Bob, walking and fighting that is our first milestone.</p>
<p>So I will be programming it all in AS3, but I have decided to push myself by using classes. Which I know about but I have never really made a piece as I plan to make this I have used classes, and wrote my own document classes but never wrote a class hierarchy as I plan to for this project.</p>
<p>So now onto the point of the post, I have started setting up classes and have a document class and a class for my main character. I have also started setting up the movement controls. I had problems to start with in that it would only allow me to use one key movement at a time, so I fixed this using an array which allows me to tell my mainCharacter class what keys are down and aren&#8217;t down. Here is my first test.</p>
<p><object width="384" height="288" data="http://joshshard.com/jjgame/TestV1.swf" type="application/x-shockwave-flash"><param name="Key Press Management" value="http://joshshard.com/jjgame/TestV1.swf" /><param name="src" value="http://joshshard.com/jjgame/TestV1.swf" /></object><br />
The image is controlled by the up, down, left and right keys.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=36</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Motion Tracking combined with Line Fade.</title>
		<link>http://joshshard.com/blog/?p=34</link>
		<comments>http://joshshard.com/blog/?p=34#comments</comments>
		<pubDate>Fri, 06 Feb 2009 20:10:13 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Experimental]]></category>

		<guid isPermaLink="false">http://www.joshshard.com/?p=34</guid>
		<description><![CDATA[So in my last tutorial I made a line that followed the mouse, I adapted it so that now it reacts to motion it is attracted but large enough movements. I did this as a small test for a project I&#8217;m working on. I will be projecting this on the floor and using tracking to [...]]]></description>
			<content:encoded><![CDATA[<p>So in my last tutorial I made a line that followed the mouse, I adapted it so that now it reacts to motion it is attracted but large enough movements. I did this as a small test for a project I&#8217;m working on. I will be projecting this on the floor and using tracking to pick up the user, as the user enters and walks across the space the line will follow them. Hopefully I will get a video up soon as for now here is a .swf using the webcam.</p>
<p><object width="384" height="288" data="http://www.joshshard.com/experimental/AttractDrawing.swf" type="application/x-shockwave-flash"><param name="Motion Tracking with Line Fade" value="http://www.joshshard.com/experimental/AttractDrawing.swf" /><param name="src" value="http://www.joshshard.com/experimental/AttractDrawing.swf" /></object></p>
<p>It needs a little bit of refining but I need to test it as a projection before I start experimenting with the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=34</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fading a Dynamic Line &#8211; Tutorial &#8211; Flash AS2</title>
		<link>http://joshshard.com/blog/?p=19</link>
		<comments>http://joshshard.com/blog/?p=19#comments</comments>
		<pubDate>Fri, 06 Feb 2009 18:59:11 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.joshshard.com/?p=19</guid>
		<description><![CDATA[This tutorial teaches you how to draw a line that follows the mouse, it fades and blurs out as you move the mouse.  It utilizes the drawing api. So to start off call the layer on your timeline actions, then open the actions window, firstly I created a few variables these control the colour of [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial teaches you how to draw a line that follows the mouse, it fades and blurs out as you move the mouse.  It utilizes the drawing api. So to start off call the layer on your timeline actions, then open the actions window, firstly I created a few variables these control the colour of the line, the thickness, the amount of blur, and the fade speed.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;"> // VARIABLES \\
var colour = 0xff0000;
var thickness = 10;
var blurAmount = 10;
var fadeSpeed = 1.5;</pre></div></div>

<p>After setting up our variables we are going to set up a 2 function one which draws the line and saves that section as a movieclip, and the other part which will fade and blur the line.  This function is for drawing the line, I called it drawLine. We create 2 variables one to pass a number to the other variable and one which creates empty movieclips to store the separate sections of line. We then set the line style. We then set we were are starting to draw the line from or each time it will draw from the same place, so we call prevX and prevY which are variables that will store our last mouse positions. We then draw a line from this position to our new position which is the current mouse X and Y position. We then give prevX and prevY the current mouse so the next time the function is called it starts from the place it finished.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">// FUNCTIONS \\
function drawLine():MovieClip {
	var depth:Number = _root.getNextHighestDepth();
	var line_mc:MovieClip = _root.createEmptyMovieClip(&quot;line&quot;+depth, depth);
	line_mc.lineStyle(thickness,colour,100);
	line_mc.moveTo(prevX,prevY);
	line_mc.lineTo(_xmouse,_ymouse);
	prevX = _xmouse;
	prevY = _ymouse;
	return line_mc;
}</pre></div></div>

<p>The next function is what we are going to call to blur and fade the parts of our line. I called mine fadeDraw. This function will be applied to our other function, so we use this to refer to the movieclip(section of line) it will be effecting. We will fade out and blur out every time we enter the frame so we put all the code in an onEnterFrame function. Firstly we make the alpha of the movieclip fade by reducing the alpha, and then we blur it. We then use an if statement to remove any movieclips that have 0 alpha this makes our .swf run more efficiently.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">function fadeDraw():Void {
	this.onEnterFrame = function():Void  {
		this._alpha -= fadeSpeed;
		this.filters = [new flash.filters.BlurFilter(blurAmount, blurAmount, 2)];
		if (this._alpha&amp;lt;0) {
			this.removeMovieClip();
		}
	};
}</pre></div></div>

<p>The final thing we do is call our functions, this I did every time the mouse is moved. This little bit of code call both our functions and applies the fade and blur to each bit.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">onMouseMove = function ():Void {
	fadeDraw.apply(drawLine());
};</pre></div></div>

<p>Try it out, <a href="http://www.joshshard.com/tutorials/drawingFade.html">here</a> is my example.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=19</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Processing to Flash AS3</title>
		<link>http://joshshard.com/blog/?p=17</link>
		<comments>http://joshshard.com/blog/?p=17#comments</comments>
		<pubDate>Fri, 30 Jan 2009 15:36:38 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Experimental]]></category>

		<guid isPermaLink="false">http://www.joshshard.com/?p=17</guid>
		<description><![CDATA[This is my first attempt at getting processing to talk to flash and it works. It uses Actionscript 3.0 and grabs an XML stream from a server you setup in processing. This just handles two variables being passed to flash. I have them traced and you can see them in the output window. I made [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first attempt at getting processing to talk to flash and it works. It uses Actionscript 3.0 and grabs an XML stream from a server you setup in processing. This just handles two variables being passed to flash. I have them traced and you can see them in the output window. I made the values increase so that you are constantly receiving different values.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;"> import processing.net.*;
&nbsp;
int port = 9001;
Server myServer;
//Variables for Sending
byte zero = 0;
int total = 299;
int total2 = 200;
&nbsp;
void setup() {
  size (200, 200);
  myServer = new Server(this,port);
}
&nbsp;
void draw () {
  total += 1;
  total2 +=2;
  myServer.write(total+&quot;,&quot;+total2);
  myServer.write(zero);
}</pre></div></div>

<p>Flash Actionscript 3</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">// ===serverCom Class=== //
// ===     created by     ===//
// ===     Josh Shard     ===//
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.DataEvent;
	import flash.events.IOErrorEvent;
	import flash.net.XMLSocket;
&nbsp;
	public class serverCom extends Sprite {
&nbsp;
		public var serialServer:XMLSocket;
&nbsp;
		public function serverCom() {
			init();
		}
		public function init():void {
			serialServer=new XMLSocket  ;
			serialServer.connect(&quot;127.0.0.1&quot;,9001);
&nbsp;
			serialServer.addEventListener(DataEvent.DATA,onReceiveData);
&nbsp;
			serialServer.addEventListener(Event.CONNECT,onServer);
			serialServer.addEventListener(Event.CLOSE,onServer);
			serialServer.addEventListener(IOErrorEvent.IO_ERROR,onServer);
		}
		// --== EVENTS ==-- \\
		public function onServer(event:Event):void {
			trace(event);
		}
		public function onReceiveData(dataEvent:DataEvent):void {
&nbsp;
			var Data:DataEvent=dataEvent;
			//trace(Data);
&nbsp;
			// This grabs the data from Data var which is the string passed
			// from our processing server.
			var test=Data.data;
			//trace(test);
&nbsp;
			// This splits the variables we are passing.
			var parts:Array=test.split(&quot;,&quot;);
			trace(&quot;parts0 this is the first variable: &quot; + parts[0]);
			trace(&quot;parts1 this is the second variable: &quot; + parts[1]);
		}
	}
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=17</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Actionscript 3 Classes, Drag Class.</title>
		<link>http://joshshard.com/blog/?p=5</link>
		<comments>http://joshshard.com/blog/?p=5#comments</comments>
		<pubDate>Thu, 29 Jan 2009 19:18:39 +0000</pubDate>
		<dc:creator>Josh Shard</dc:creator>
				<category><![CDATA[Experimental]]></category>

		<guid isPermaLink="false">http://www.joshshard.com/?p=5</guid>
		<description><![CDATA[This was my first attempt at actionscript 3.0, i had heard it was more of a programming language then the previous 2.
So Alex Fish, a good friend of mine and me, began to look at actionscript 3.0, my background was in flash with as2, while Alex had previous programming experience with processing, css, html, and [...]]]></description>
			<content:encoded><![CDATA[<p>This was my first attempt at actionscript 3.0, i had heard it was more of a programming language then the previous 2.</p>
<p>So Alex Fish, a good friend of mine and me, began to look at actionscript 3.0, my background was in flash with as2, while Alex had previous programming experience with processing, css, html, and various other web languages. So we began to delve into the unknown&#8230;</p>
<p>By lunch time we had learnt some of the key basics of actionscript 3.0, one of the main think I learnt was about classes I was use to programming everything on the first frame of my file, now i just simply made a document class and compiled and voila, nothing in the .fla. So we began to work together, we decided we wanted to make a drag and drop class because this would be a useful class that would be helpful for me in the future, and also be something Alex could use with his latest project.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">// AS3 drag and drop class
// Alex Fish and Josh Shard
&nbsp;
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.TextField;
import flash.events.MouseEvent;
import flash.events.Event;
&nbsp;
public class drag extends Sprite {
private var eventSprite:Sprite;
private var dragging=0;
private var speed=1;
private var xMouse:Number;
private var yMouse:Number;
public function drag() {
init();
}
private function init():void {
//Stops the movie changing scale
stage.scaleMode=StageScaleMode.NO_SCALE;
//
//Places in the top left of window
stage.align=StageAlign.TOP_LEFT;
&nbsp;
//
//Place Sprite on the stage
eventSprite=new Sprite;
addChild(eventSprite);
&nbsp;
//
// Draws a circle and fills it with the hexidecimal colour.
eventSprite.graphics.beginFill(0xffffff);
eventSprite.graphics.drawCircle(0,0,50);
eventSprite.graphics.endFill();
//
//Places the circle(sprite) in the centre of the stage
eventSprite.x=stage.stageWidth / 2;
eventSprite.y=stage.stageHeight / 2;
&nbsp;
//
//Adds code to listen for mouse down and mouse up
eventSprite.addEventListener(MouseEvent.MOUSE_DOWN,onMousePressedDown);
eventSprite.addEventListener(MouseEvent.MOUSE_UP,onMouseReleased);
eventSprite.addEventListener(Event.ENTER_FRAME,onLoop);
&nbsp;
}
//
// This is our on enterframe function to start the drag. And stop it.
private function onLoop(event:Event):void {
//trace(&quot;entering frame&quot;);
if (dragging == 1) {
eventSprite.x=mouseX;
eventSprite.y=mouseY;
}
eventSprite.x += speed;
}
//
// This function handles the event when the mouse is pressed
// on our sprite.
private function onMousePressedDown(event:MouseEvent):void {
//trace(&quot;Mouse Down&quot;);
dragging=1;
speed += 1;
}
//
// This function handles the event when the mouse is released
// on our sprite.
private function onMouseReleased(event:MouseEvent):void {
//trace(&quot;Mouse Up&quot;);
dragging=0;
}
}
}</pre></td></tr></table></div>

<p>This is the code we put together, and worked pretty well, I added a few additions to mine, including a speed factor meaning everytime you press down the ball gets faster. It also moves towards the edge of the screen which was a bit of simple animation I was exploring. You can check the compiled version <a href="http://joshshard.com/drag.swf" target="_blank">here</a>.  Over the next weeks I will be exploring more actionscript while also adding some recent as2 tutorials to my blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshshard.com/blog/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
