<?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>Producerism &#187; Blog</title>
	<atom:link href="http://producerism.com/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://producerism.com</link>
	<description>Thomas Gorence: Interactive Developer (Orlando, FL)</description>
	<lastBuildDate>Fri, 11 Jun 2010 15:43:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Tom-as3-gotchi (Flash Game Tutorial) Part 4</title>
		<link>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-4/</link>
		<comments>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-4/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 15:12:19 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tom-as3-gotchi]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=601</guid>
		<description><![CDATA[For the fourth part to this tutorial, as promised, I will start introducing some graphics.  I started by sketching out a very rough example of the room our virtual character will live in, then I sketched out a gui - which for now is really just a rectangular frame. After a bit of time using my Wacom [...]]]></description>
			<content:encoded><![CDATA[<p>For the fourth part to this tutorial, as promised, I will start introducing some graphics.  I started by sketching out a very rough example of the room our virtual character will live in, then I sketched out a <a href="http://en.wikipedia.org/wiki/Graphical_user_interface">gui</a> - which for now is really just a rectangular frame.  </p>
<p><img class=" size-medium wp-image-606" title="tom-as3-gotchi-sketch1" src="http://producerism.com/wp-content/uploads/2010/06/tom-as3-gotchi-sketch1-300x180.jpg" alt="" width="300" height="180" /> <img class="size-medium wp-image-602" title="tom-as3-gotchi-sketch-frame1" src="http://producerism.com/wp-content/uploads/2010/06/tom-as3-gotchi-sketch-frame1-300x214.jpg" alt="" width="300" height="214" /> </p>
<p>After a bit of time using my Wacom in the Flash IDE, I recreated the sketches in vector format, and then separated them into MovieClips and Graphic symbols.  </p>
<p><img class="aligncenter size-full wp-image-605" title="tom-as3-gotchi-screenshot1" src="http://producerism.com/wp-content/uploads/2010/06/tom-as3-gotchi-screenshot1.jpg" alt="" width="640" height="480" /> </p>
<p><span id="more-601"></span>Here is an example of how I decided to organize all of the different assets for now.  Notice that two of the items, Gui and gauge, have linkage properties, which is why their "Export" property isn't blank like the rest of the symbols in the library.  </p>
<p><img class="aligncenter size-full wp-image-604" title="tom-as3-gotchi-library1" src="http://producerism.com/wp-content/uploads/2010/06/tom-as3-gotchi-library1.jpg" alt="" width="332" height="625" /></p>
<p>First, let's take a look at the code and assets in the Gui class.  Here's a screenshot of the assets, and their instance names: </p>
<p><img class="aligncenter size-full wp-image-603" title="tom-as3-gotchi-gui-class" src="http://producerism.com/wp-content/uploads/2010/06/tom-as3-gotchi-gui-class.jpg" alt="" width="535" height="386" /> </p>
<p>And now, here is the code to go along with the Gui class:</p>
<pre class="brush:as3">package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	public class Gui extends MovieClip
	{
		// Event constants
		public static const APPLE_CLICKED:String = "apple clicked";
		public static const CHEESEBURGER_CLICKED:String = "cheeseburger clicked";

		// Gui elements
		public var age_txt:TextField;
		public var weight_txt:TextField;

		public var boredomGauge:Gauge;
		public var hungerGauge:Gauge;
		public var thirstGauge:Gauge;

		public var apple:MovieClip;
		public var cheeseburger:MovieClip;

		public function Gui()
		{
			// set labels
			boredomGauge.label.text = "Boredom";
			hungerGauge.label.text = "Hunger";
			thirstGauge.label.text = "Thirst";

			// add button function to apple
			apple.addEventListener(MouseEvent.CLICK, function(evt:Event) { dispatchEvent(new Event(APPLE_CLICKED)); }, false, 0, true);
			apple.buttonMode = true;
			apple.useHandCursor = true;

			// add button function to cheeseburger
			cheeseburger.addEventListener(MouseEvent.CLICK, function(evt:Event) { dispatchEvent(new Event(CHEESEBURGER_CLICKED)); }, false, 0, true);
			cheeseburger.buttonMode = true;
			cheeseburger.useHandCursor = true;
		}

		public function update($tom:Tom):void
		{
			// update all Gui fields based on $tom variable
			age_txt.text = String($tom.age);
			weight_txt.text = String($tom.weight);
			boredomGauge.value = $tom.boredom;
			hungerGauge.value = $tom.hunger;
			thirstGauge.value = $tom.thirst;
		}

	}

}</pre>
<p>Since it's all new, let's go through it line by line.  </p>
<p>First, you will notice two public static constants, <strong>APPLE_CLICKED</strong> and <strong>CHEESEBURGER_CLICKED</strong>, which will serve as temporary Event descriptions.  We then define our textfields, <strong>age_txt</strong> and <strong>weight_txt</strong>.  </p>
<p>Then we define the gauges, <strong>boredomGauge</strong>, <strong>hungerGauge</strong>, and <strong>thirstGauge</strong>, which make use of another new class, <strong>Gauge.as</strong>.  Finally, we need something to click on, which interacts with our character.  For now, I've created two simple MovieClips and cleverly named them <strong>apple </strong>and <strong>cheeseburger</strong>, but  in the future I will connect these to the <strong>Food.as class</strong>.  </p>
<p>Other than the declarations we just went over, there are only 2 functions to the Gui.as class right now, the constructor function, <strong>Gui()</strong>, and <strong>update()</strong>.  The constructor function is pretty simple, we just assign labels to the gauges.  Each item which uses the <strong>Gauge.as</strong> class is basically a MovieClip with certain child item, including a textfield named <strong>label</strong>.  Next, we add MouseEvent listeners to the <strong>apple </strong>and <strong>cheeseburger</strong> MovieClips, which in turn dispatch an event.  This may seem redundant, but it's one way of separating the logic in the Gui fro the game logic, which will reveal it's use as the project increases in complexity.  </p>
<p>The remaining function, <strong>update()</strong>, is used to refresh the gui to reflect all of the current values of the passed <strong>Tom.as</strong> object.  </p>
<p>For Part 5 we'll explore the Gauge.as class, and then see everything in action so far!</p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SlotMas3chine (Slot Machine AS3 Tutorial)</title>
		<link>http://producerism.com/blog/slotmas3chine-slot-machine-as3-tutorial/</link>
		<comments>http://producerism.com/blog/slotmas3chine-slot-machine-as3-tutorial/#comments</comments>
		<pubDate>Thu, 27 May 2010 17:48:49 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SlotMas3chine]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=587</guid>
		<description><![CDATA[I put together a quick example of a slot machine in AS3 in about 15 minutes, and under 100 lines.  It can still be optimized a great deal, and I will probably make some updates to this in the near future.  One of the requests of the example, was an ability to hold matching reels.  [...]]]></description>
			<content:encoded><![CDATA[<p>I put together a quick example of a slot machine in AS3 in about 15 minutes, and under 100 lines.  It can still be optimized a great deal, and I will probably make some updates to this in the near future.  One of the requests of the example, was an ability to <em>hold matching reels</em>.  So in this example, once 2 of the reels in the slot machine match, those will not respond to the<strong> spin()</strong> function anymore.  This will be changed around a bit future updates, to act more like a typical slot machine that does not have this feature.</p>
<p><a href="http://wonderfl.net/c/5BNK">here it is in action on wonderfl</a></p>
<p>The explanation (or tutorial) part of this post will be complete  soon.  I will also optimize the code in the next couple of posts.  Until then, take a look at the code and try to understand what's  going on.<span id="more-587"></span></p>
<pre class="brush:as3">package
{
    import flash.display.Sprite;

    public class SlotMachine extends Sprite {

        private var _credits:uint = 4; // start with $20

        private var _slotReel1:SlotReel;
        private var _slotReel2:SlotReel;
        private var _slotReel3:SlotReel;

        public function SlotMachine()
        {   

            _slotReel1 = new SlotReel();
            _slotReel2 = new SlotReel();
            _slotReel3 = new SlotReel();

            spinReels();
            spinReels();
            spinReels();
            spinReels();
        }

        private function spinReels():void
        {
            if (_credits)
            {
                _credits--; // costs $1 per spin

                _slotReel1.spin();
                _slotReel2.spin();
                _slotReel3.spin();

                // check for matches
                if (_slotReel1.value == _slotReel2.value &amp;&amp; _slotReel1.value == _slotReel3.value)
                {
                    trace("win!");
                    _credits += 1000;
                }
                else if (_slotReel1.value == _slotReel2.value)
                {
                    _slotReel1.hold = true;
                    _slotReel2.hold = true;
                }
                else if (_slotReel1.value == _slotReel3.value)
                {
                    _slotReel1.hold = true;
                    _slotReel3.hold = true;
                }
                else if (_slotReel2.value == _slotReel3.value)
                {
                    _slotReel2.hold = true;
                    _slotReel3.hold = true;
                }

                trace(_slotReel1.value + " " + _slotReel2.value + " " + _slotReel3.value+" credits left: "+_credits);
            } else {
                trace("out of credits!");
            }

        }

    }
}

import flash.display.MovieClip;

class SlotReel extends MovieClip {

    private var _numberOfSlotFrames:uint = 12;
    private var _currentSlotFrame:uint;
    public var hold:Boolean;

    public function SlotReel(){ super(); }

    public function spin():void
    {
        if (!hold)
        {
            _currentSlotFrame = Math.round(Math.random() * (_numberOfSlotFrames- 1) + 1);
            gotoAndStop(_currentSlotFrame);
        }
    }

    public function get value():uint { return _currentSlotFrame; }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/slotmas3chine-slot-machine-as3-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tom-as3-gotchi (Flash Game Tutorial) Part 3</title>
		<link>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-3/</link>
		<comments>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-3/#comments</comments>
		<pubDate>Fri, 21 May 2010 15:33:47 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tom-as3-gotchi]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=562</guid>
		<description><![CDATA[If you haven't been following along, make sure to check out part 1 and part 2 of this tutorial first.  In the third part of this tutorial, I will cover the whole concept of getter/setter functions, along with the benefits of doing so, instead of using public variables.  A new class will be created too, [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven't been following along, make sure to check out <a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-1/">part 1</a> and <a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-2/">part 2</a> of this tutorial first.  In the third part of this tutorial, I will cover the whole concept of getter/setter functions, along with the benefits of doing so, instead of using public variables.  A new class will be created too, <strong>Food.as</strong>.  Keep in mind that any or all of this code can change, move around or get scrapped completely, since this is somewhat of an "organic" tutorial.</p>
<p>To get started, let's have a look at what's changed in the <strong>Tom.as</strong> class.  First, look at the getter function:</p>
<pre class="brush:as3">public function get weight():Number {
	// when returning weight, round to 1 decimal
	// this way "weight" getter function will return 201.5
	// while private variable _weight will still be accurate
	return Math.round(_weight * 10) / 10;
}
</pre>
<p><span id="more-562"></span><br />
We could have easily made <strong>_weight</strong> a public variable, but then it will return a very long number (201.12395323).  Most digital scales aren't even that accurate, nor do most people need to know their weight to that many decimal points.  Programming wise, we want to make sure Tom's weight is as accurate as possible, so behind the scenes, we are storing the entire decimal within the private variable <strong>_weight</strong>, but whenever something outside of the <strong>Tom.as</strong> class requests to know Tom's weight, Tom will return his weight rounded to the nearest single decimal through the <strong><em>weight</em></strong> getter method (which to outsiders, looks like a variable instead of a function).  You may be thinking, "but I could just get Tom's weight, then round it myself!"  That's true, however I prefer doing this within the getter method, so that I can take care of formatting in one place, instead of many different places.</p>
<p>I also added the rest of the simple getter functions, in case I want to create similar functions to the <strong>weight </strong>function above.</p>
<pre class="brush:as3">// getter functions for private variables
public function get health():String { return _health; }
public function get mood():String 	{ return _mood; }
public function get hunger():uint { return _hunger; }
public function get thirst():uint { return _thirst; }
public function get boredom():uint { return _boredom; }
public function get age():uint { return _age; }
</pre>
<p>The previous tutorial (<a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-2/">Part 2</a>) covered getter functions, so this shouldn't seem brand new.  We haven't covered setter functions yet though, so let's take a look at that:</p>
<pre class="brush:as3">// example setter function
public function set weight(value:Number):void
{
	// we shouldn't allow the weight variable to be changed
	// unless it's through the eat() or drink() functions
	throw new Error("Hey, no cheating your diet!");
}
</pre>
<p>Let's take a step back for a second.  Right now, we have a "Tom" class, that has a private variable <strong>_weight</strong>, which can only be accessed from within the <strong>Tom.as</strong> file.  One way to think about it is this: since <strong>_weight</strong> is private, it's almost like a secret that "Tom" is keeping to himself.  Unless there is a public function created to expose that variable to the rest of the world, there will be no way to alter or check on Tom's weight.  If we make <strong>_weight</strong> a public variable, then it solves the problem, but creates another: Tom should only be able to gain or lose weight by eating or exercising, not by magically adding or removing X pounds.</p>
<p>Being able to write the following should not be possible, because you can't do it in the real world (and therefore, we won't allow it in this game).</p>
<pre class="brush:as3">tom.weight = 100; // this is cheating!
tom.weight = tom.weight - 50; // losing 50 pounds is that easy?
tom.weight++; // where did those extra lbs just come from?
</pre>
<p>In the <strong>weight </strong>setter function, we throw an error whenever code tries to change the <strong>_weight</strong> variable directly.  All three of the lines posted above will throw the following error:</p>
<pre class="brush:as3">throw new Error("Hey, no cheating your diet!");
</pre>
<p>Instead, Tom will only be able to gain or lose weight through new functions that we'll create, starting with <strong>eat()</strong>:</p>
<p><strong>Tom.as</strong></p>
<pre class="brush:as3">// public functions
public function eat($food:Food):void
{
	_weight += $food.calories / Food.CALORIES_IN_A_POUND;
	trace("After eating that " + $food.name + ", Tom now weighs " + weight);
}
</pre>
<p>Here you can see the only place within the <strong>Tom.as</strong> class which alters the <strong>_weight</strong> variable.  To restate one more time, the only way to change Tom's weight outside of the <strong>Tom.as</strong> class, is to call this new <strong>eat()</strong> function.  Also, whenever this <strong>eat()</strong> function is called, Tom will trace out a message that states what he ate, and how much he weighs after eating.  To fully understand what's going on, we also need to analyze the new <strong>Food.as</strong> class, since the <strong>eat()</strong> function is expecting you to pass it a Food variable:</p>
<p><strong>Food.as:</strong></p>
<pre class="brush:as3">package
{
	public class Food
	{

		public var calories:uint;
		public var name:String;

		public static const CALORIES_IN_A_POUND:uint = 3500;

		public function Food($name:String, $calories:uint)
		{
			name = $name;
			calories = $calories;
		}
	}
}
</pre>
<p>That is the <em>entire </em>class so far.  Right away you may notice that I'm using public variables this time!  I did this for a couple of reasons: to show how public variables can be easily used instead of private variables with getter/setter methods, and also because it just made more sense in this case.  Also notice the constant I've created, called <strong>CALORIES_IN_A_POUND</strong>, which is equal to 3500.  Using all capital letters for constants, and underscores for spaces is a programming standard.  It's not required by flash, but this is a good habit to get into.</p>
<p>This is also the first function in which we are accepting arguments:</p>
<p><strong>Food.as:</strong></p>
<pre class="brush:as3">public function Food($name:String, $calories:uint)
</pre>
<p>Remember, that within this <strong>Food.as</strong> file, since the "<strong>Food</strong>" function has the same name of the class, "<strong>Food</strong>," it's called a constructor function, and is called when a new Food item is created.  The <strong>$name:String</strong> and <strong>$calories:uint</strong> within the parenthesis denote that in order to create a new Food item, a name must be supplied in string format ("Apple"), and calories must be provided as a positive (unsigned) integer (165).  The dollar sign in front of those argument variables is a new feature to AS3 which I've recently discovered, and is a preference thing.  Feel free to omit the dollar signs, I like to use them for all of my argument variables, which helps prevent conflicts with duplicate variable names.</p>
<p>The very next line stores the supplied arguments (<strong>$name</strong> and <strong>$calories</strong>) into private variables within the Food item.  To create a Food item, this is the code:</p>
<pre class="brush:as3">var someFood:Food = new Food("Burrito", 500);
</pre>
<p>Which creates a new Food item with the name "Burrito," along with storing 500 calories within that Food item (declared <strong>someFood</strong>).</p>
<p>And that's it for the <strong>Tom.as</strong> and <strong>Food.as</strong> classes.  The only other changes to cover are within the <strong>TomAS3Gotchi.as</strong> class:</p>
<p><strong>TomAS3Gotchi.as:</strong></p>
<pre class="brush:as3">// feed Tom some food
_tom.eat(new Food("apple", 500));
_tom.eat(new Food("cheeseburger", 3000));

// this will trigger an error
_tom.weight = 100;
</pre>
<p>The first line is calling our new public <strong>eat()</strong> function within the <strong>Tom.as</strong> class.  Since <strong>eat()</strong> requires a Food variable, one is created on that same line, using <strong>Food("apple", 500)</strong>.  This creates a new Food object with the name "apple" and 500 calories.  The next line is basically the same, but as you can see the Cheeseburger has many more calories.  Doing some quick mental math, you can see that 3000+500 = 3500, which is the same number of calories in a pound.  This should show us that Tom gains a full pound after eating both items.</p>
<p><img class="alignnone size-full wp-image-565" title="tom-as3-gotchi-flash-output4" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-flash-output4.jpg" alt="" width="426" height="107" /></p>
<p>The next line is a deliberate attempt to create an error.  We added code in the weight setter function of our <strong>Tom.as</strong> class, so that an Error will be thrown whenever Tom's weight is changed by any method other than the <strong>eat()</strong> function.  Let's see what happens:</p>
<p><img class="alignnone size-full wp-image-566" title="tom-as3-gotchi-error1" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-error1.jpg" alt="" width="600" height="400" /></p>
<p>Just as expected, an error was thrown with our custom message, "Hey, no cheating your diet!"</p>
<p>If you read the full error message in the pop-up window, you can see exactly how that error was thrown.  Start from the bottom and work your way up.  The last line says "<em>at TomAS3Gotchi()[D:\projects\producerism\Tom-as3-gotchi\src\TomAS3Gotchi.as:26]</em>" which means that the error all started with line #26 of <strong>TomAS3Gotchi.as</strong>:</p>
<p><strong>line #26 of TomAS3Gotchi.as:</strong></p>
<pre class="brush:as3">_tom.weight = 100;
</pre>
<p>The line above that is "<em>at Tom/set weight()[D:\projects\producerism\Tom-as3-gotchi\src\Tom.as:50]</em>"</p>
<p><strong>line #50 of Tom.as:</strong></p>
<pre class="brush:as3">throw new Error("Hey, no cheating your diet!");
</pre>
<p>And there you have it - first, the <strong>TomAS3Gotchi.as</strong> class tried to set Tom's weight through the setter property on line #26.  Next, within the setter property of <strong>Tom.as</strong> (line 50), we throw an error.  Of course, this wasn't a huge revelation since we knew this error would happen, and caused it to error on purpose.  The point is, you may run into an error in another project somewhere, and need to figure out where it's coming from.  By following these lines from the bottom to the top, you will be able to figure out the source of most errors.</p>
<p>And that's it for now!  I promised some buttons and a crude GUI, so that will be covered in the next part of this series.</p>
<p>Tom-as3-gotchi Flash Game Tutorial - <a href="http://github.com/downloads/producerism/Tom-as3-gotchi/Tom-as3-gotchi-part-3.zip">zip</a>,   <a href="http://github.com/producerism/Tom-as3-gotchi">git</a>, or <a href="http://wonderfl.net/c/pSE1/">wonderfl</a>. (SVN will be posted soon)</p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tom-as3-gotchi (Flash Game Tutorial) Part 2</title>
		<link>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-2/</link>
		<comments>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-2/#comments</comments>
		<pubDate>Thu, 20 May 2010 19:29:23 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tom-as3-gotchi]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=503</guid>
		<description><![CDATA[Continuing with our game from part 1, we will now start adding some code to our 2 classes, Tom.as and TomAS3Gotchi.as.  When we left off, the Tom class was basically an empty shell to store various information (health, food, hunger, boredom, etc.) and it had a simple constructor function (when a new Tom class is [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing with our game from <a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-1/">part 1</a>, we will now start adding some code to our 2 classes, <strong>Tom.as</strong> and <strong>TomAS3Gotchi.as</strong>.  When we left off, the Tom class was basically an empty shell to store various information (health, food, hunger, boredom, etc.) and it had a simple constructor function (when a new Tom class is created, it traces "Hello, I'm Tom!").</p>
<p>Logically, when a new Tom is created, he should have default values set (for example, weight, height, mood and more).  As the project gets bigger and more complex, I may create a class just to store default values, but for now we'll just add them all to the top of <strong>Tom.as</strong>.  There are 3 main changes:<span id="more-503"></span></p>
<p>First, I've created new <strong>static constants</strong> for all defaults.  <strong>Static </strong>basically means that the placeholder (DEFAULT_AGE) will <em>always </em>exist within the Tom class.  <strong>Constant </strong>means that the <em>value </em>of that <em>constant </em>(DEFAULT_AGE=25) will not change while the program is running.  Since DEFAULT_AGE is a <em>constant</em>, trying to write DEFAULT_AGE = 10 anywhere else in the code will cause an error.  The <strong>_age</strong> placeholder is a <em>variable</em> though (defined with <strong>var </strong>keyword instead of <strong>const</strong>), so that means it <strong><em>can </em></strong>change while the program is running.  This is all sort of unimportant now, and more of a personal preference - but I thought it would be useful to explain it in a little bit of detail.</p>
<pre class="brush:as3">public class Tom
{
// Constants and Defaults
private static const DEFAULT_WEIGHT :uint     = 200;
private static const DEFAULT_AGE    :uint     = 25;
private static const DEFAULT_MOOD   :String = "Happy";
private static const DEFAULT_HEALTH :String = "Healthy";</pre>
<p>Next, I've added some more code to the constructor function.  Again, the constructor function is the function with the <em>same name as the class</em> (in this case, "Tom"), which is run automatically when the class is created.  I've added code that sets the _weight, _age, _mood and _health <strong>variables </strong>to the default <strong>constants </strong>defined at the top of the class.  I also set _hunger, _thirst and _boredom to 0.  I could have created another set of constants (DEFAULT_HUNGER:uint = 0) but I believe that they will all start at 0 for now, so creating a specific constant just for that seems a bit redundant.</p>
<pre class="brush:as3">public function Tom()
{
	// constructor function
	trace("Hi, I'm Tom!");

	// set defaults
	_weight = DEFAULT_WEIGHT;
	_age = DEFAULT_AGE;
	_mood = DEFAULT_MOOD;
	_health = DEFAULT_HEALTH;

	// set hunger, thirst and boredom to 0
	_hunger = _thirst = _boredom = 0;
}</pre>
<p>Finally, I created 2 <strong><em>getter </em>functions</strong>, called <strong>health()</strong> and <strong>mood()</strong>.  Notice that the health() getter function simply returns the _health variable, and likewise, the mood() function returns _mood.  The reason for creating these functions, are to allow other classes (like TomAS3Gotchi.as) to access information about the Tom.as class.   Without creating <strong>public </strong>functions like health() and mood(), there would be no way to get the status of Tom's health or mood, since those variables are set to <strong>private</strong>.</p>
<pre class="brush:as3">public function get health():String { return _health; }
public function get mood():String     { return _mood; }</pre>
<p>The difference between a getter function, and a regular function is pretty simple.  A regular function is written as so:</p>
<pre class="brush:as3">public function myHealth():String { return "Healthy";  }</pre>
<p>and is used like this:</p>
<pre class="brush:as3">trace(Tom.myHealth());</pre>
<p>which will trace out "Healthy" when run.</p>
<p>A getter function is a little different.  To write one, you simple add the word "get" in front of the function:</p>
<pre class="brush:as3">public function get myHealth():String {return "Healthy";  }</pre>
<p>and is used a bit differently too:</p>
<pre class="brush:as3">trace(Tom.myHealth);</pre>
<p>which traces the same message, "Healthy" when run.  The biggest difference is that you can treat a getter function the same as a variable (notice there are no parenthesis after <strong>myHealth </strong>in this example).  When we get into <strong><em>setter </em>functions</strong> later in this series, it will make more and more sense.</p>
<p>The next change is very simple - and that's just to check to see if our changes are working.  In the TomAS3Gotchi.as class, we will add 2 lines to the constructor function, TomAS3Gotchi().</p>
<p><strong>TomAS3Gotchi.as</strong></p>
<pre class="brush:as3">package
{
	import flash.display.Sprite;

	/**
	 * ...
	 * @author T@IDEAS
	 * Main class of the entire project.  This is the file that is actually compiled to SWF.
	 */
	[SWF(width="800", height="600", backgroundColor="#cccccc", frameRate="30")]
	public class TomAS3Gotchi extends Sprite
	{
		private var _tom:Tom;

		public function TomAS3Gotchi()
		{
			_tom = new Tom();
			trace(_tom.health);
			trace(_tom.mood);
		}
	}
}
</pre>
<p>Now, when the program is compiled, you get the same trace as before ("Hello, I'm Tom") along with 2 new messages: "Healthy" and "Happy."</p>
<p><img class="alignnone size-full wp-image-523" title="tom-as3-gotchi-flash-output3" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-flash-output3.jpg" alt="" width="426" height="107" /></p>
<p>Seeing those 2 messages means that not only are the default settings working correctly, but so are our getter functions.  In the next part to this series, I will create similar getter functions for the rest of the variables (hunger, thirst, boredom, etc.) and we will begin to create a very crude GUI for our game, so that there are buttons to click among other things.</p>
<p>All of these files are available  to download:</p>
<p>Tom-as3-gotchi Flash Game Tutorial - <a href="http://github.com/downloads/producerism/Tom-as3-gotchi/Tom-as3-gotchi-part-2.zip">zip</a>,  <a href="http://github.com/producerism/Tom-as3-gotchi">git</a>, <a href="http://tom-as3-gotchi.googlecode.com/svn/trunk/">svn</a>, or <a href="http://wonderfl.net/c/pSE1/">wonderfl</a>.</p>
<p><a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-3/">Continue to Part 3</a></p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tom-as3-gotchi (Flash Game Tutorial) Part 1</title>
		<link>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-1/</link>
		<comments>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-1/#comments</comments>
		<pubDate>Wed, 19 May 2010 14:54:56 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tom-as3-gotchi]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=489</guid>
		<description><![CDATA[Welcome to my first tutorial of many.  As I mentioned in an earlier post, I believe game programming to be a great way of learning any language, since it can force you to think a little more than a simple form-based application.  For this series, I want to create a variation of the traditional Tamagotchi [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to my first tutorial of many.  As I mentioned in an earlier post, I believe game programming to be a great way of learning any language, since it can force you to think a little more than a simple form-based application.  For this series, I want to create a variation of the traditional Tamagotchi virtual pet, which will allow me to cover a few different topics and programs in the process.  I've playfully named this a "Tom-as3-gotchi," which should be obvious to most (for the rest, consider it a free riddle).</p>
<h2>Game Concept</h2>
<p>Before writing a single line of code, I want to have a solid concept to design my game around.  The <a href="http://en.wikipedia.org/wiki/Tamagotchi">Tamagotchi</a> page on Wikipedia, which was surprisingly sparse on information, states the core functions.  I'll be using those as a reference, specifically the functions for:</p>
<ul>
<li>Feeding the Tom-as3-gotchi a piece of food or a snack.</li>
<li>Playing games with the Tom-as3-gotchi.</li>
<li>Cleaning up a Tom-as3-gotchi's waste.</li>
<li>Checking Tom-as3-gotchi's age, discipline, hunger, happiness and other statistics.</li>
</ul>
<p>I've omitted the ability to connect with friends for now, but may decide to introduce that later down the line.<span id="more-489"></span></p>
<p>At this point, it's tempting to just open up the Flash IDE (or my preference, <a href="http://www.flashdevelop.org/">FlashDevelop</a>) and get started, but we're still not half way there.  As I see it, there are 3 main components to the entire game.  First, the actual character, Tom (Tom-as3-gotchi), which has basic needs (needs to be fed, entertained and kept in shape).  We also need a world for Tom to live in - for the scope of this game, his "World" is a room.  Within that world exist many objects (food, computer, bed, toilet, etc.), each of which represent the third component, "Object."  I'm a visual person (what game programmer isn't?) so after I know the general direction I want to go in, sketching it out on paper can help me focus.  After spending 15-20 minutes, I came up with this simple list of components and functions:</p>
<div class="block clear"><img class="alignnone size-full wp-image-500" title="tom-as3-gotchi-sketch1" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-sketch1.jpg" alt="" width="355" height="278" /></div>
<div class="block">
<h3>Tom</h3>
<ul>
<li>health</li>
<li>weight</li>
<li>age</li>
<li>mood</li>
<li>hunger</li>
<li>thirst</li>
<li>boredom</li>
</ul>
</div>
<div class="block">
<h3>Room/World</h3>
<ul>
<li>time</li>
<li>weather</li>
<li>temperature</li>
<li>humidity</li>
</ul>
</div>
<div class="block">
<h3>Objects</h3>
<ul>
<li>fan</li>
<li>computer</li>
<li>bathroom</li>
<li>bedroom</li>
</ul>
</div>
<p>Again, this could all change in the near future, but at least the concept is beginning to take shape.  Since "Tom" is the main component to all of this, I will focus on him first.  Next step, we can almost get into some as3 coding!</p>
<h2>Project Structure</h2>
<p>Another important factor in game design and programming in general is your workflow.  I typically structure my projects by using folders and naming conventions.  For starters, I almost always start with 3 main folders: <strong>assets</strong>, <strong>deploy </strong>and <strong>src</strong>.</p>
<p><img class="alignnone size-full wp-image-504" title="tom-as3-gotchi-structure1" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-structure1.jpg" alt="" width="619" height="150" /></p>
<h3>assets</h3>
<p>This folder will contain "non-deliverables" meaning all reference materials like .psd (photoshop), .ai (illustrator), .pdf, .txt, .doc, uncompressed videos (.mov, .avi, etc.) and just about anything else that won't need to be uploaded when everything is done.  Any images or other assets that are embedded into your app at compile-time will also go in here (like .wav, .jpg, .png and .gif files).</p>
<h3>deploy</h3>
<p>The deploy folder will include all of your deliverables, or the files that are "delivered" to the end-user.  This usually includes .html, .css, .php, .swf, .mp3, .jpg, .png, .flv, .xml and any other assets that are loaded in dynamically at run-time.  This is also where you will set Flash (or FlashDevelop) to publish your SWF files into.</p>
<h3>src</h3>
<p>If you haven't figured it out already, <strong>src </strong>is short for <strong><em>source</em></strong>.  Not that it really needs to be shortened, but this is a naming convention that I've picked up over time.  The source folder is where you will store all of your source code.  This includes .fla, .as, .mxml and a few others.</p>
<h3>Source Control</h3>
<p>You may also notice a folder named ".git" on the left panel in the screenshot above, and if you are really paying attention to details, you will also see that all of the folders have little green checkmarks on them.  Without going to far into the rabbit-hole of source control, the <a href="http://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read">tl;dr</a> version is that source control lets you keep a complete history of all changes you make to code (and assets), along with ways to restore previous versions of the entire project, or of individual files.  I will not be covering how to set up source control in this series, as I would prefer to just focus on the game.  I have been using Subversion for source control for a few years, and recently started moving over to Git.  In fact, along with being my first tutorial series, this is also my first project using git.  For anyone that wants to follow along, I've posted <a href="http://github.com/producerism/Tom-as3-gotchi">Tom-as3-gotchi on github</a>, and <a href="https://code.google.com/p/tom-as3-gotchi/">google code</a>.  By using source control, it makes it very easy to make huge changes, without worrying about breaking things - and it makes working on a project with multiple people a little easier.</p>
<h3>Getting to the Code!</h3>
<p>Finally, we've developed an overall concept (well, at least we started to),  and we've setup our directory structure (albeit basic right now).  If this were less about programming, and more about game design, the next step would probably be to start sketching ideas out on paper, and even coming up with some mock-ups and rough graphics.  However, since this is about the programming, let's code!</p>
<p>The first step is to setup our main component of the game, Tom.  You may notice that I use <strong>uint</strong> instead of <strong>int </strong>or <strong>Number </strong>for numeric variables.  This is another preference thing, and also a bit of optimization.  A <strong>Number </strong>type can go into the decimals, which isn't necessary for our game, and the main difference between a regular integer (<strong>int</strong>) and an unsigned-integer (<strong>uint</strong>) is that a regular integer can be negative (-1000) but a uint must be 0 or higher.  Again, this makes sense because our age, weight, or other values will never be less than 0.</p>
<p><strong>Tom.as</strong></p>
<pre class="brush:as3">package
{

	/**
	 * ...
	 * @author Thomas Gorence
	 * Base class for the main component of the Tom-as3-gotchi game.
	 */
	public class Tom
	{
		// Weight and Age are integers
		private var _weight:uint;
		private var _age:uint;

		// hunger, thirst and boredom will be rated from 0-10
		private var _hunger:uint;
		private var _thirst:uint;
		private var _boredom:uint;

		// health and mood will be represented by strings
		private var _health:String;
		private var _mood:String;

		public function Tom()
		{
			// constructor function
			trace("Hi, I'm Tom!");
		}

	}

}
</pre>
<p>Notice that our class, Tom, does not extend Movieclip or Sprite, or anything else - meaning that Tom is an <strong><em>abstract class</em></strong>.  I've also created a few private variables to store information about Tom.  They all begin with an underscore, which I use to denote a private variable versus a public variable.  It's another personal preference thing, and also allows me to create getter/setter methods easily, which I will get into later.  The class is named "Tom," and you will notice a public function in the class with the same name ("public function Tom").  This is known as the <strong><em>constructor function</em></strong>, which runs when the class is instantiated.  To put that into English, the constructor function is run once, automatically, whenever a new "Tom" is added.  In this case, when a new Tom object is added to the project, it will trace out "Hi, I'm, Tom!"</p>
<p>Before wrapping up, take a look at the other file in this project.</p>
<p><strong>TomAS3Gotchi.as</strong></p>
<pre class="brush:as3">package
{
	import flash.display.Sprite;

	/**
	 * ...
	 * @author T@IDEAS
	 * Main class of the entire project.  This is the file that is actually compiled to SWF.
	 */
	[SWF(width="800", height="600", backgroundColor="#cccccc", frameRate="30")]
	public class TomAS3Gotchi extends Sprite
	{
		private var _tom:Tom;

		public function TomAS3Gotchi()
		{
			_tom = new Tom();
		}

	}

}</pre>
<p>So this is the actual file that we will use to compile.  If you don't have Flash IDE or <a href="http://www.flashdevelop.org/">FlashDevelop</a> installed (and have no other way of using flash), this<a href="http://wonderfl.net/c/pSE1/"> Tom-as3-Gotchi Flash Game Programming Tutorial</a> is also hosted on <a href="http://wonderfl.net/c/pSE1/">wonderfl</a>, so you can program and view it for free.  I'm using <a href="http://www.flashdevelop.org/">FlashDevelop</a> (it's free, windows only) but you can also use the Flash IDE by creating a new FLA file, and then in the stage properties, set the <strong>Document Class</strong> to "TomAS3Gotchi" and save that FLA file into the same folder as TomAS3Gotchi.as (the <strong>src </strong>folder).</p>
<p><img title="tom-as3-gotchi-document-class" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-document-class.jpg" alt="" width="426" height="107" /></p>
<p>Note: if you are using Flash IDE, you will have to go into Publish Settings and set the SWF output to "../deploy/TomAS3Gotchi.swf" and uncheck HTML output.  If you want to set height, width, framerate and background color, those also must be done in the stage properties, as Flash IDE will ignore line #10 altogether.</p>
<p><img class="alignnone  size-full wp-image-510" title="tom-as3-gotchi-publish-settings" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-publish-settings.jpg" alt="" width="426" height="190" /></p>
<p>If you compile/publish the project in either FlashDevelop or the Flash IDE, you should see the message trace out, indicating that our Tom class was successfully created (or instantiated) and the constructor function was run.</p>
<p><strong>Flash IDE:</strong></p>
<p><img class="alignnone size-full wp-image-514" title="tom-as3-gotchi-flash-output1" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-flash-output1.jpg" alt="" width="426" height="107" /></p>
<p><strong>FlashDevelop:</strong></p>
<p><img class="alignnone size-full wp-image-515" title="tom-as3-gotchi-flash-output2" src="http://producerism.com/wp-content/uploads/2010/05/tom-as3-gotchi-flash-output2.jpg" alt="" width="426" height="107" /></p>
<p>Well, that's good for now.  Again, all of these files are available to download:</p>
<p>Tom-as3-gotchi Flash Game Tutorial - <a href="http://github.com/downloads/producerism/Tom-as3-gotchi/Tom-as3-gotchi-part-1.zip">zip</a>, <a href="http://github.com/producerism/Tom-as3-gotchi">git</a>, <a href="http://tom-as3-gotchi.googlecode.com/svn/trunk/">svn</a>, or <a href="http://wonderfl.net/c/pSE1/">wonderfl</a>.</p>
<p><a href="http://producerism.com/tutorials/tom-as3-gotchi/tom-as3-gotchi-flash-game-tutorial-part-2/">Continue to Part 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/tom-as3-gotchi-flash-game-tutorial-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World</title>
		<link>http://producerism.com/blog/hello-world/</link>
		<comments>http://producerism.com/blog/hello-world/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:02:26 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=487</guid>
		<description><![CDATA[I won't bore you with the Wikipedia entry on "Hello World," which is pretty dry anyways (even for Wikipedia).  For just about every programmer on the face of the planet, Hello World represents their first approach to a new language.  For me, blogging is sort of a new language, along with writing tutorials.  I've constantly [...]]]></description>
			<content:encoded><![CDATA[<p>I won't bore you with the Wikipedia entry on "<a href="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</a>," which is pretty dry anyways (even for Wikipedia).  For just about every programmer on the face of the planet, Hello World represents their first approach to a new language.  For me, blogging is sort of a new language, along with writing tutorials.  I've constantly follow lots of flash blogs, including <a href="http://theflashblog.com/">TheFlashBlog</a>, <a href="http://www.tink.ws/blog/">tink</a>, <a href="http://www.bytearray.org/">ByteArray</a>, <a href="http://www.bit-101.com/blog/">Bit-101</a>, <a href="http://www.anttikupila.com/">AnttiKupila</a>, <a href="http://blog.kevinhoyt.org/">Kevin Hoyt</a>, <a href="http://www.as3dp.com/">Actionscript 3.0 Design Patterns</a>, <a href="http://www.emanueleferonato.com/">Emanuele Feronato</a>, <a href="http://www.lostinactionscript.com/blog/">Lost in Actionscript</a>, <a href="http://sebleedelisle.com/">Seb Lee-Delisle</a>, <a href="http://jessewarden.com/">Jesse Warden</a>, and plenty others that I will list as time goes on.  I can also attribute most of my learning to following tutorials, although I haven't written many yet.</p>
<p>My goal is to write something new everyday, although realistically I'll manage about 3-4 posts per week.  Hopefully someone out there will get some use to these tutorials - but in line with one of my personal mantras (experience - expectation = happiness), I'll be writing for my own personal benefit at first... and if others can learn from this as well, all the better.</p>
<p>That being said, you can <a href="http://producerism.com/tutorials/">see the tutorials section here</a>.</p>
<p>At work (IDEAS in Orlando, FL) I've been introducing my coworkers/friends to AS3, and recently figured out that the best way to teach, is through practical example.  I guess I should have just started with the obvious!  After reviewing a few other websites that teach Flash Programming, I've been inspired by the good and the bad.  Lee Brimelow's<a href="http://www.gotoandlearn.com/"> gotoAndLearn</a> was inspiring in that I've personally watched it start from a simple tutorial site, into the Flash Blog of an Adobe Platform Evangelist.  I was also inspired by some very popular, but not-so-impressive sites, which got me thinking, "if they are teaching flash successfully to thousands, with ugly code..."</p>
<p>I also believe game programming is a good way of learning - since it often involves lots of different moving parts.  I'll leave my philosophy on game design to another post, but the <a href="http://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read">tl;dr</a> version is that before programming a game, the concept and gameplay should be fleshed out in detail, without any regards to technology.  Meaning, the concept of the game should be fun and exciting even if it were text-based, or a board-game, or a first-person shooter, and so on.  Of course, not all games are created this way, but it's how I like to approach them, as opposed to finding some game-engine and just working on the gameplay and fun as you code.</p>
<p>So... while you may not have learned anything yet, I promise to give it my best shot!  If you ever have any comments, questions or suggestions for new topics, please comment!  And of course, <a href="http://producerism.com/tutorials/">check out the tutorial section!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another Developer on Apple vs Adobe (Flash)</title>
		<link>http://producerism.com/blog/yet-another-developers-take-on-apple-vs-adobe-flash/</link>
		<comments>http://producerism.com/blog/yet-another-developers-take-on-apple-vs-adobe-flash/#comments</comments>
		<pubDate>Sat, 01 May 2010 00:01:07 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=471</guid>
		<description><![CDATA[It's only been one day since Steve Jobs posted his Thoughts on Flash, and mobile developer blogs are already at full-swing. In fact, this drama has become such a major issue, that there is even a discussion on Flash dying as a whole, not just in terms of the mobile market. This is a bit [...]]]></description>
			<content:encoded><![CDATA[<p>It's only been one day since <a href="http://www.apple.com/hotnews/thoughts-on-flash/">Steve Jobs posted his Thoughts on Flash</a>, and mobile developer blogs are already at full-swing.  In fact, this drama has become such a major issue, that there is even a discussion on Flash dying as a whole, not just in terms of the mobile market.  This is a bit different from the typical technodrama of trademark infringements and patents for a few reasons. Adobe and Apple have a history, and in the past have relied on each other to evolve - and while that's true of many conflicts in technology, this one is very personal to many different people from developers and creative professionals to end-users.  Even some of the official (and especially unofficial) statements have been personal, passive-aggressive and sarcastic.  And I find it all fascinating, in a reality-tv-tabloid-celebrity-leaked-video kind of way.  With all of that said, I'd really like to analyze (read: think out loud  about) all of this from a few different perspectives:<br />
<span id="more-471"></span></p>
<h1>Developing</h1>
<p>Without getting into definitions of what "open" means, I can speak from personal experience.  Developing for Flash wasn't always a treat.  The IDE was hard to work with, and would frequently leave me with corrupt files and crashes.  Slowly I learned to work in external files using tools like SEPY to save time from crashing.  There were also lots of hacks and workarounds that became common practice.  There were a few open source solutions for flash, but most of it was intermediate to advanced.  Then, I discovered FlashDevelop, which completely eliminated the barrier for programming.  I was able to download the free Flex SDK and compile to the latest versions of Flash and AIR, all without using free software.  That may not be a textbook definition of "open," but it's sure as hell more open than developing for iPhone and iPad.</p>
<p>Programming for the iPhone was actually a lot of fun, and as I mentioned before there's something inspiring about it. Creating software for the latest must-have-gadget is thrilling, and hearing about all the success stories from simple (and not so simple) apps gave me lots of motivation.  Learning Objective-C was rewarding, and I didn't have many problems setting up or using XCode or Interface Builder.  The problem I had was with testing and "provisioning."  I will be associating negative emotions to that particular word for quite some time after experiences with the App Store.</p>
<p>Most non-programmers aren't really aware of the development perspective for Apple either.  It's been tense, as they seem to approve or reject apps on a whim, and selectively allow content based on ambiguous statements which seem to revolve around some kind of moral highground.  None of that really sits well with me, and I assume many other developers.  Finally, it's been said over and over, but end-users don't really care what was used to developed their products.  End users don't care about GoLive, FrontPage, Dreamweaver, Coda or Notepad.  They don't care if you use mootools, jquery or dojo.  They certainly don't care if you used XCode, Flash CS5 or Mono.  The only ones that really care what you used, are the creators of each respective development tool.</p>
<h1>Mobile Apps</h1>
<p>Before getting into any particular side of this debate, I have to say it's a bit foolish making any sort of judgment calls this early in the game.  Flash hasn't even scratched the surface of mobile apps, yet some people are already declaring the victors. I can absolutely agree that Apple led the way in rolling out this whole <em>mobile app marketplace</em> business model, and making it tangible - but having a head-start doesn't guarantee lifelong success (although I will be so daring as to suggest Apple may be doing this for a while).</p>
<p>As of right now, Apple is pretty much dominating the mobile apps world compared to Blackberry, Android and other smartphones.  However, the entire process has been bittersweet for developers.  Small shops and independent programmers have been able to turn hobby projects into rags-to-riches stories because of iPhone and iPad development, and that has really been a huge inspiration for even more innovation.  However, that same inspiration has also been stifled along the way.    I haven't made anything for Android yet, and I haven't attempted to port  anything in Flash to a mobile device.  I've created a few native iPhone  apps, a Blackberry app, and I have developed quite a few mobile  websites.</p>
<p>I can't wait to see what sort of impact Flash will have on the mobile marketplace, but until then I'll bite my tongue on that whole issue, which in my opinion is at the heart of this entire episode.</p>
<h1>Touchscreens</h1>
<p>One element of Steve's post that struck me as particularly humorous was regarding rollover states, and indicating that Flash was outdated because it was designed for using a mouse and keyboard.  The reason I find this humorous is due to the fact I've been working on various touchscreen applications over the past few years using Flash, Flex and AIR.  In fact, while Steve was writing that blog post, I was making some final touches to a touchscreen kiosk application made entirely in Flash CS3.</p>
<p>In fact, when the Microsoft Surface was announced, there were already working multi-touch libraries for Flash being shared around on the internet along with DIY instructions on making multi-touch interfaces.  None of this was exclusive to Flash, as most (if not all)  was ported from other languages - but the point is, Flash has constantly been able to adapt and evolve to however developers see fit.  I'm not even sure Adobe deserves all of the credit for the innovation that's been made by the community, but they sure as hell have embraced it.</p>
<h1>Video</h1>
<p>The point was made that before Flash, when you wanted to watch a video online you had to choose between Real Player, Quicktime and Windows Media.  It was <em>standard</em> to offer video in multiple formats, because nobody was ready to take sides or make up their mind.  At least not as ready as Apple and Microsoft seem to be today about H.264.  As of 2007, Flash has supported H.264.  If HTML5 is going to support it, more the merrier.  The way I see it - if you have an H.264 video file, it's ready to play in almost any modern browser or media device.  However, if you decide to house that video in a custom Flash player, all of a sudden it cannot be played on an iPhone/iPad.  This has nothing to do with Flash being locked-down or closed.  The video is there, it's just that Apple is refusing to acknowledge it, because of the wrapper it's in.</p>
<p>I don't have any problems with HTML5 taking over in online video, in fact I embrace it.  I don't have anything against HTML, or CSS, or XML, or JavaScript, or SQL, or any other scripting language.  I'm a bit confused why H.264 support in HTML5 is supposed to kill Flash.  It's still up to the browsers to implement the actual support, is it not?</p>
<h1>Gaming</h1>
<p>While Apple has been innovating mobile devices, slick hardware and outstanding UI design, they still haven't cornered much of the gaming market outside of mobile apps.  Despite Jobs' reference to having more entertainment apps than any other platform, the amount of Flash games already on the internet dwarfs the selection in the App Store.  If quality is supposed to be a metric, I would also venture to say that the quality of games available (in terms of immersion and playability along with optimization) from Flash developers is not an issue.  Apple has most definitely wet their appetite, and are probably loving the huge gaming market that they have tapped into.  Along with mobile-apps, only time will tell.</p>
<h1>/rant</h1>
<p>I'd love to program a game or app in a single format, and be able to  deploy to anything.  And that's sort of the point of this whole HTML5 /  web standards argument.  The problem is, anyone who has been programming  to "web standards" for the last decade (or more) knows how laughable it  is.  Yes, Firefox, Chrome, Safari, Opera and IE9 will all (supposedly)  support HTML5.  The cynic (or perhaps the realist) in me has to wonder  if this is the same type of web-standard compliance that bestows upon us  little gems like margin, padding and float issues?  Of course it's  possible to create a website that looks identical in all browsers, down  to the pixel.  It may even be possible to do it without any hacks or  browser-specific code.  It's just a very tedious and at times  frustrating process.</p>
<p>It seemed like Flash was attempting to take over HTML, or JavaScript, or desktop programming, or anything.  It was made originally as an animation solution, but due to the community has evolved to being a creative tool, to fill in gaps for all sorts of different functions.  Flash has also been one of the few development tools where I can truly write once and publish for multiple platforms and mediums.  It's got an incredibly talented and passionate development community... and while nothing is really too big to fail, it just seems that Flash has come all this way, it's a bit naive to think they would ever die without putting up a huge fight.</p>
<p>I will make a few updates to this post over the weekend, sprinkling in some extra quotes, links and references.</p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/yet-another-developers-take-on-apple-vs-adobe-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sid Meier Builds a Game in 48 Hours</title>
		<link>http://producerism.com/blog/sid-meier-builds-a-game-in-48-hours/</link>
		<comments>http://producerism.com/blog/sid-meier-builds-a-game-in-48-hours/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 11:41:24 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=467</guid>
		<description><![CDATA[Ryan Meier hosted a game competition at Michigan State University called the "Wolverine Soft 48 hour Game Design Contest." His father, Sid Meier, was not only a judge, but also entered for fun. Ever since I was a kid, games like SimAnt and the original SimCity really influenced the way I look at games. It [...]]]></description>
			<content:encoded><![CDATA[<p>Ryan Meier hosted a game competition at Michigan State University called the "Wolverine Soft 48 hour Game Design Contest." His father, Sid Meier, was not only a judge, but also entered for fun.  Ever since I was a kid, games like SimAnt and the original SimCity really influenced the way I look at games.  It was before impressive graphics or 3d textures, yet the actual gameplay was impressively complex.</p>
<p>This video documents the entire process, and captures the excitement and passion of game programming.  As I dive more and more into programming games in flash, iphone and more, it's become obvious that programming the actual game is the "easy" part.  The real magic is making the game playable - but more importantly, fun.</p>
<p>http://ca.kotaku.com/5517715/watch-civilizations-creator-build-a-game-in-48-hours</p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/sid-meier-builds-a-game-in-48-hours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Website Design!</title>
		<link>http://producerism.com/blog/new-website-design/</link>
		<comments>http://producerism.com/blog/new-website-design/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 03:42:02 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=219</guid>
		<description><![CDATA[It started to seem like the old site design was a bit dated.  Dated to around 2006 to be exact.  Lots has changed since then, and it was about time for an update.  After spending lots of time gathering up assets and screenshots, I realized how much I've actually done over the last few years.  [...]]]></description>
			<content:encoded><![CDATA[<p>It started to seem like the old site design was a bit dated.  Dated to around 2006 to be exact.  Lots has changed since then, and it was about time for an update.  After spending lots of time gathering up assets and screenshots, I realized how much I've actually done over the last few years.  I hope you enjoy looking through the site, as I've enjoyed making everything on here.  Please check back for updates, tutorials, reviews and rants on Flash, Flex, Air, Actionscript, PHP, amfphp, smf (simple machines forum), wordpress, javascript, jquery, mootools, box2d, mysql, arduino, phidgets, photoshop, illustrator, after effects, cinema 4d, audio production and so much more.</p>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/new-website-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>smf2amfphp</title>
		<link>http://producerism.com/blog/smf2amfphp/</link>
		<comments>http://producerism.com/blog/smf2amfphp/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 14:31:11 +0000</pubDate>
		<dc:creator>T</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://producerism.com/?p=320</guid>
		<description><![CDATA[I have been bouncing between wordpress, joomla and expression engine for the past couple years trying to figure out a decent way to integrate a streaming audio player into my forums, without altering the database, or intruding on SMF at all. Anyways, long story short, I ditched all the “bridges” and just made a non-intrusive [...]]]></description>
			<content:encoded><![CDATA[<p>I have been bouncing between wordpress, joomla and expression engine for the past couple years trying to figure out a decent way to integrate a streaming audio player into my forums, without altering the database, or intruding on SMF at all.</p>
<p>Anyways, long story short, I ditched all the “bridges” and just made a non-intrusive package (well, started to make it at least) that feeds data into flash using a series of php functions, that connect directly to the smf database.</p>
<p>I’ve put together a practical example of using this class here:</p>
<p><a href="http://hiphopproduction.com/forum/index.php?topic=2139.0">HipHopProduction.com Beat Meet Player</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://hiphopproduction.com/beatmeet/bm_player.swf" /><embed type="application/x-shockwave-flash" width="500" height="300" src="http://hiphopproduction.com/beatmeet/bm_player.swf"></embed></object></p>
<p>It will load a given topic (in this case, each drop-down item is associated with a topic that has lots of replies with attachments), search that topic for mp3 attachments, and add them to the list. Then by clicking on any of the names in the list, that user’s mp3 will begin to stream.</p>
<p>The functions that I’ve got working so far are getNews, getMembers, getMemberGroups, getPollEntries, getPoll, getBoards, getBoardCategories, getBoardModerators, getMemberInfo, validateMember, and getTopicAttachments.</p>
<p>Read on for the source code and a functional example.<br />
<span id="more-320"></span><br />
amfphp service file:</p>
<pre class="brush: php; wrap-lines: false;">// +----------------------------------------------------------------------+
// | Filname: smf2amfphp.php                                           |
// +----------------------------------------------------------------------+
// | Copyright (c) http://www.producerism.com                              |
// +----------------------------------------------------------------------+
class smf2amfphp
{
    function smf2amfphp()
    {
        $conn = mysql_pconnect("localhost","username","password");
        mysql_select_db("smf_database");
    }

    /** getPoll
    * This method returns poll information
    * @param      pollID
    */
    function getPoll($pollID)
    {
        $query = "SELECT * FROM smf_polls WHERE ID_POLL = $pollID";
        $result = mysql_query($query);

        if(!mysql_num_rows($result)){
            return "Poll ID: ".$pollID." not found!";
        }else{
            $record = mysql_fetch_array($result);
            return $record;
        }

    } // end func

    /** getPollEntries
    * This method returns poll entries
    * @param      pollID
    */
    function getPollEntries($pollID)
    {
        $query = "SELECT * FROM smf_poll_choices WHERE ID_POLL = $pollID";
        $result = mysql_query($query);

        if(!mysql_num_rows($result)) {
        return "Poll ID: ".$pollID." not found!";
        }else{
        $tmp = array();
        while($record = mysql_fetch_array($result)){
        array_push($tmp,$record);
        }
        return $tmp;
        }
    } // end func

    /** getTopicAttachments
    * This method returns attachment filenames within a topic
    * @param      topicID
    */
    function getTopicAttachments($topicID)
    {
        $query = "SELECT att.filename, msg.posterName FROM smf_messages msg, smf_attachments att WHERE msg.ID_MSG = att.ID_MSG AND (msg.ID_BOARD = 8 OR msg.ID_BOARD = 11) AND msg.ID_TOPIC = $topicID";
        $result = mysql_query($query);

        if(!mysql_num_rows($result)) {
            return false;
        }else{
            $tmp = array();
            while($record = mysql_fetch_array($result)){
                array_push($tmp,$record);
            }
            return $tmp;
        }
    } // end func

    /** getMemberInfo
    * This method returns member information
    * @param      memberID
    */
    function getMemberInfo($memberID)
    {
        $query = "SELECT * FROM smf_members WHERE ID_MEMBER = $memberID";
        $result = mysql_query($query);

        if(!mysql_num_rows($result)) {
            return "Member ID: ".$memberID." not found!";
        }else{
            $record = mysql_fetch_array($result);
            return $record;
        }
    } // end func

    /** getMemberInfo
    * This method returns poll information
    * @param      memberName    - smf member name
    * @param      passwd      - smf password (this should be a HASH value, unless sha1 is true)
    * @param      sha1         - set to true if passing the actual password (NOT RECOMMENENDED!)
    */
    function validateMember($memberName, $passwd, $sha1=false)
    {
        if($sha1) $passwd = sha1($memberName.$passwd);

        $query = "SELECT * FROM smf_members WHERE memberName = '$memberName' AND passwd = '$passwd'";
        $result = mysql_query($query);

        if(!mysql_num_rows($result)) {
            return false;
        }else{
            $record = mysql_fetch_array($result);
            return $record;
        }
    } // end func
} // end class</pre>
<p>flash as3 function that connects to amfphp, and calls one of the functions listed above:</p>
<pre class="brush: as3; wrap-lines: false;">function onLoginClick(evt)
{
    var memberName, passwd;

    memberName = StringUtil.replace(login_txt.text, "\r", "");
    passwd = SHA1.hash(StringUtil.replace(login_txt.text + password_txt.text, "\r", ""));

    _amfphpConnection = new amfphp(GATEWAY_URL, "smf2amfphp.validateMember", new Array(memberName, passwd), { onResponse:onLogin } );
}</pre>
<p>as you can see by the SHA1.hash function, I am using the corelib encryption functions by Adobe in my flash file, so the password never leaves the client.</p>
<p>in keeping with everything else smf, i decided to simplify the class API i’m working on. For example, this is now the code for validating a login: (assuming there are 3 objects: login_txt, password_txt and the login button being clicked that triggers onLoginClick)</p>
<pre class="brush: as3; wrap-lines: false;">function onLoginClick(evt)
{
    smf2amfphp.validateMember(login_txt.text, login_txt.text+password_txt.text, onLogin);
}

function onLogin(evt)
{
    if (evt)
    {
        // login successful!
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://producerism.com/blog/smf2amfphp/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
Page Caching using disk (enhanced) (user agent is rejected)

Served from: producerism.com @ 2010-09-05 05:06:28 -->