<?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/"
		xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>untoldentertainment.com &#187; Tutorials</title>
	<atom:link href="http://www.untoldentertainment.com/blog/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.untoldentertainment.com/blog</link>
	<description>We Make Flash Games</description>
	<lastBuildDate>Wed, 01 Feb 2012 15:18:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<copyright>Copyright &#xA9; untoldentertainment.com 2011 </copyright>
	<managingEditor>ryan@untoldentertainment.com (untoldentertainment.com)</managingEditor>
	<webMaster>ryan@untoldentertainment.com (untoldentertainment.com)</webMaster>
	<image>
		<url>http://www.untoldentertainment.com/blog/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>untoldentertainment.com</title>
		<link>http://www.untoldentertainment.com/blog</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>We Make Flash Games</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &#38; Culture" />
	<itunes:author>untoldentertainment.com</itunes:author>
	<itunes:owner>
		<itunes:name>untoldentertainment.com</itunes:name>
		<itunes:email>ryan@untoldentertainment.com</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.untoldentertainment.com/blog/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Flash to iOS: A Step-by-Step Tutorial (Part 5)</title>
		<link>http://www.untoldentertainment.com/blog/2011/12/21/flash-to-ios-a-step-by-step-tutorial-part-5/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/12/21/flash-to-ios-a-step-by-step-tutorial-part-5/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 16:54:38 +0000</pubDate>
		<dc:creator>Sina Kashanizadeh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=4272</guid>
		<description><![CDATA[This is the fifth part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch. Jump to other parts in the series: Part 1 &#8211; Sign up [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<div class="displayed">
<img src="http://www.untoldentertainment.com/blog/img/2011_12_07/iPadAIR.png" alt="Flash to iOS: A Step-by-Step Tutorial" />
</div>
<p></center></p>
<p>This is the fifth part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch.</p>
<p>Jump to other parts in the series:</p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/" title="Flash to iOS: A Step-by-Step Tutorial (Part 1)"><b>Part 1</b> &#8211; Sign up for an Apple iOS Developer Account</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 2)"><b>Part 2</b> &#8211; Obtain your Signing Certificate &#038; Mobile Provisioning Profile, and create your App ID</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 3)"><b>Part 3</b> &#8211; Use FlashDevelop to build your mobile AIR app</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" title="Flash to iOS: A Step-by-Step Tutorial (Part 4)"><b>Part 4</b> &#8211; Modify your project settings and test your app on an Apple device</a>
</ul>
<h2>Distribution Certificate</h2>
<p>Now that you&#8217;ve tested your app and it&#8217;s to your liking, guess you want to put it up on the App Store? Never fear, my friend! I will now show you how to get your app uploaded on the App Store so the whole world can ignore it and buy <b>Angry Birds</b> instead.</p>
<p>This process of distribution is a bittersweet one. It&#8217;s sweet because it&#8217;s <em>extremely similar</em> to the development process that you just went through, so you should be familiar with the convoluted certificates and hoops you have to jump through at Apple&#8217;s pleasure. It&#8217;s bitter because it&#8217;s <em>extremely similar</em> to the development process that you just went through.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/groundhogDay.jpg" alt="Groundhog Day" /></p>
<p>Something about this seems awfully familiar &#8230;
</p></div>
<p>Enough talk. Let’s get cracking!</p>
<h2>Generate a Signing Certificate Request</h2>
<p>Remember that OpenSSL program that you installed in <a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Guide Part 2 by Untold Entertainment">Part 2 of this tutorial</a>? You have to open that bad boy up again to create another <b>Certificate Signing Request</b>. Now, it <em>is</em> possible to just use your old Signing Certificate &#8211; however, just to be super clear and to avoid any confusion or difficulty, we&#8217;re going to create another one.</p>
<p><b>Note:</b> We&#8217;ll use this new Signing Certificate Request to get a <b>Distribution Certificate</b> rather than a <b>Development Certificate</b>.</p>
<ol>
<li>Open a command prompt window. You can do this by clicking the Windows <b>Start</b> button and typing in <b>cmd</b> in the search field. Alternately, you can also hold the Windows key on your keyboard and hit the &#8220;R&#8221; key (for &#8220;Run&#8221;), then type <b>cmd</b> and hit Enter.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/cmd.jpg" alt="Windows CLI" /></p>
</div>
<li>Once you are in the command prompt, navigate to your Open SSL <b>bin</b> folder. Depending on where you installed it, you will have to navigate to a different path than in this example. (i hope you installed Open SSL in a location that you can remember!)  Check <a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Guide Part 2 by Untold Entertainment">Part 2</a> if you need a refresher on Windows CLI (Command Line Interpreter) commands.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/cd.jpg" alt="Open SSL folder" /></p>
</div>
<li>Punch this command into the CLI and hit the ENTER key when you’re finished:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl genrsa -out mykey.key 2048</pre></div></div>

<p>You should see this response:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/response.jpg" alt="Response" /></p>
</div>
<li>Next, type (or highlight the line, right-click, choose &#8220;Copy&#8221;, and right-click/&#8221;Paste&#8221; in the CLI):

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest  -subj &quot;/emailAddress=yourAddress<span style="color: #33cc33;">@</span>example.com, CN=John Doe, C=US&quot;</pre></div></div>

<p>Now, before you hit ENTER you’ll want to edit a couple of things. First, replace &#8220;John Doe&#8221; with your own name or company name. Then replace the &#8220;yourAddress@example.com&#8221; email with your own email. Press ENTER.</p>
<p>You should get a message similar to this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/response2.jpg" alt="Response 2" /></p>
</div>
<p>You just generated the <b>Signing Certificate Request file</b> that you&#8217;ll use to ask Apple for your <b>Distribution Signing Certificate</b>. The Signing Certificate Request file is located in the <b>bin</b> folder of your Open SSL install. It has a <b>.certSigningRequest</b> file extension and should look like this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/signingRequest.jpg" alt="Signing Certificate" /></p>
</div>
</ol>
<h2>Obtain a Signing Certificate for Distribution</h2>
<p>You have to upload your <b>Signing Certificate Request file</b> to the <b>Apple Provisioning Portal</b> to get your <b>Distribution Signing Certificate</b>.  Onward.</p>
<p><b>Note:</b> There have been instances where this upload does not work with Google Chrome. Just to be safe, use another browser like Firefox.</p>
<ol>
<li>Navigate to the <a href="http://developer.apple.com/devcenter/ios/index.action" title="Apple iOS Provisioning Portal">Apple iOS Provisioning Portal</a> within the Dev Center.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/portal.jpg" alt="Apple Provisioning Portal" /></p>
</div>
<li>Log in with your developer account and click on <b>Certificates</b>.
<li>Click on the <b>Distribution</b> tab.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/distribution.jpg" alt="Apple Provisioning Portal" /></p>
</div>
<p><b>Note:</b> In our previous tutorials, you requested a certificate from the <b>Development</b> tab.  An app signed with a Development certificate cannot be successfully submitted to the Apple App Store.</p>
<p>If you have an old <b>Distribution Certificate</b> because you&#8217;ve made a prior app, and you&#8217;d still like to follow along, you can go ahead and <b>Revoke</b> it. Revoking the Certificate will not affect your apps that are already on the App Store, because the Certificate is primarily used during the upload process so that Apple can identify you.</p>
<p><b>Note:</b> I recommend revoking an existing Certificate because Apple seems to issue only one Certificate per Team Agent. You must revoke any existing Certificate to be able to request another. Why is it set up like this? I have no idea.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/revoke.jpg" alt="Revoke your Apple Signing Certificate" /></p>
</div>
<li>If you don&#8217;t have a pre-existing <b>Distribution Signing Certificate</b>, you can just go ahead and click <b>Request Certificate</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/requestCertificate.jpg" alt="Request your Apple Signing Certificate" /></p>
</div>
<p>On the next screen, you will upload the <b>Signing Certificate Request file</b> that you generated in the previous section.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/request.jpg" alt="Request" /></p>
</div>
<li>Click the <b>Browse</b> button and navigate to the OpenSSL <b>bin</b> folder.
<li>Select the <b>Signing Certificate Request file</b> and click <b>Submit</b>.  When you are finished, you&#8217;ll see your <b>Distribution Signing Certificate</b> ready to download from the web page.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/yourCertificate.jpg" alt="Your Apple Signing Certificate" /></p>
</div>
</ol>
<p>Don&#8217;t download your <b>Distribution Certificate</b> quite yet. You still need to create an <b>App ID</b> and a <b>Mobile Provisioning Profile</b>.</p>
<h2>Create a New App ID</h2>
<p>When deciding what you want your App ID to be, you have two choices:</p>
<ul>
<li>Create an entirely new App ID
<li>Use the Existing App ID that you create in <a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial by Untold Entertainment">Part 2</a>
</ul>
<p>If you want to use your existing App ID, then just skip to the next section. If for some reason you don’t like the name of your App ID, go ahead and make a new App ID, following the steps outlined in <a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial Part 2 by Untold Entertainment">Part 2</a>.</p>
<h2>Create a Mobile Provisioning Profile for Distribution</h2>
<p>Now that you have an App ID, you can create your <b>Mobile Provisioning Profile</b>.</p>
<ol>
<li> Within the Provisioning Portal website, click <b>Provisioning</b> in the sidebar.
<li>Click the <b>Distribution</b> tab.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/newProfile.jpg" alt="New Provisioning Profile" /></p>
</div>
<p>In previous tutorials, you created a <b>Development</b> profile for testing.  You won&#8217;t be able to upload your app to the Apple App Store unless you create a <b>Distribution</b> profile, so make sure you select the correct tab.</p>
<p>You can either create a new <b>Provisioning Profile</b>, or modify an existing one.  Modifying an existing profile if you want to switch between <b>App Store</b> and <b>Ad Hoc</b> distribution. If you&#8217;ve never created a Distribution profile, read on. Instructions for modifying a profile are in the section following.</p>
<li>Click on <b>New Profile</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/newProfileButton.jpg" alt="New Provisioning Profile Button" /></p>
</div>
<p><b>Note:</b> You&#8217;ll only see this option if you are the fee-paying Team Admin.</p>
<li>In the next section, you&#8217;ll have to fill out a bunch of options. The first option is the <b>Distribution Method</b>. As you can see, you can choose between <b>App Store</b> and <b>Ad Hoc</b>.
<ul>
<li>Choose App Store if you are completely satisfied with your app and you want to submit it to Apple for review. If all goes well, then your app will be released whenever Apple deems it worthy.
<li>The Ad Hoc option can be thought of as a closed beta for your app. When you choose Ad Hoc, you are able to release your app to a maximum of 100 people, and only they will have access to it. Your App will NOT appear in the public App Store if you choose Ad Hoc.
</ul>
<p><b>Note:</b> Notice when you choose <b>App Store</b>, the &#8220;Devices&#8221; option is greyed out. When you choose <b>Ad Hoc</b>, it allows you to choose a number of devices that you have registered. The <b>App Store option</b> releases your app on the public App Store, so it doesn&#8217;t make sense to target specific devices.</p>
<li>Your <b>Profile Name</b> is the name that you want for your <b>Provisioning Profile</b>. The <b>Distribution Certificate</b> that you created should be visible here.
<li>Finally, you have to choose which <b>App ID</b> with which you want to register your <b>Provisioning Profile</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/profileOptions.jpg" alt="Profile Options" /></p>
</div>
<li>Click <b>Submit</b>.
<li>You should ee a list of the <b>Provisioning Profiles</b> that you&#8217;ve created. Click <b>download</b> on the <b>Provisioning Profile</b> that you just created, and save it to you computer.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/saveIt.jpg" alt="Save Your Provisioning Profile" /></p>
</div>
</ol>
<h2>Modify your Provisioning Profile</h2>
<p><b>Note:</b> If you&#8217;re not modifying an existing <b>Provisioning Profile</b> (say, from <b>Ad Hoc</b> to <b>App Store</b>), skip over this section.</p>
<ol>
<li>Within the <b>Provisioning Portal</b> website, click <b>Provisioning</b> in the sidebar.
<li>Click the <b>Distribution</b> tab.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/newProfile.jpg" alt="New Provisioning Profile" /></p>
</div>
<li>Click <b>Modify</b> on the <b>Provisioning Profile</b> that you want to reuse.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/modifyProfile.jpg" alt="Modify Provisioning Profile" /></p>
</div>
<li>Switch to either <b>Ad Hoc</b> or <b>App Store</b>. The distinction between these two options is explained in the preceding section.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/edit.jpg" alt="Edit Provisioning Profile" /></p>
</div>
<li>Click <b>Submit</b>.
<li>You should see a list of the <b>Provisioning Profiles</b> that you&#8217;ve created. Click <b>download</b> on the <b>Provisioning Profile</b> that you just modified, and save it to your computer.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/saveIt.jpg" alt="Save Your Provisioning Profile" /></p>
</div>
</ol>
<h2>Download your Distribution Certificate</h2>
<p>You just need to download the <b>Distribution Signing Certificate</b> that you created at the top of this tutorial,  and then you are ready to bundle your <b>.ipa</b> file to submit to the App Store.</p>
<ol>
<li>Click on the <b>Certificates</b> section in the sidebar.
<li>Click the <b>Distribution</b> tab.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/distribution.jpg" alt="Apple Provisioning Portal" /></p>
</div>
<li>You&#8217;ll see that your <b>Distribution Signing Certificate</b> is ready to download. You can also see that it contains the <b>Distribution Provisioning Profile</b> that you just made.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/ready.jpg" alt="Your Certificate is Ready" /></p>
</div>
</ol>
<li>Click download and save the file to your computer. Just to make things easier, you can save that certificate in the Open SSL <b>bin</b> folder, where your <b>Certificate Signing Request</b> file is sitting.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/hooray.jpg" alt="Hooray!" /></p>
</div>
</ol>
<p><b>Note:</b> Make sure not to get confused between your <em>Development</em> Certificate and Profile, and your <em>Distribution</em> Certificate and Profile.  You won&#8217;t be able to upload your app to the App Store if you accidentally use the Distribution set of certs in these next steps.</p>
<h2>Convert the Signing Certificate to a .p12 File</h2>
<p>You&#8217;ll have to perform the .p12 conversion on your Certificate again, as you did in an earlier tutorial.  Here are the steps:</p>
<ol>
<li>Open up your command prompt.
<li>Navigate to your Open SSL bin folder.
<li>Copy and paste this command:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl x509 -in distribution_identity.cer -inform DER -out distribution_identity.pem -outform PEM</pre></div></div>

<p>After you enter that command, you&#8217;ll see a .pem file show up in your OpenSSL <b>bin</b> folder.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/pem.jpg" alt=".pem file" /></p>
</div>
<li>Copy and paste this command in the CLI:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl pkcs12 -export -inkey mykey.key -in distribution_identity.pem -out iphone_dev.p12</pre></div></div>

<p><b>Note:</b> These are the exact same commands that you used for our Development Certificate in an earlier tutorial, except that the file name has been changed from &#8220;development&#8221; to &#8220;distribution&#8221;.</p>
<li>After you punch in the command, enter a password and then verify that password. Make sure the password is something that you will remember. (Save it in a .txt file! – Ed.)
<p><b>Note:</b> Remember that you may get an error mentioning a &#8220;random state&#8221;. Just type in the command set <b>RANDFILE=.rnd</b> and it should fix the problem for you.</p>
<li>Navigate to the <b>bin</b> folder in your Open SSL directory and you should see your <b>.p12</b> file. Hooray!
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_20/p12.jpg" alt=".p12 file" /></p>
</div>
</ol>
<h2>Hello, Planet</h2>
<p>As we mentioned off the top, much of this is familiar territory.  With all of your Distribution certs sorted out, you&#8217;re ready to bundle up your final <b>.ipa</b> file and foist it onto an unsuspecting public.  In the next tutorial, you&#8217;ll follow familiar instructions to bind your certs to your <b>.ipa</b>, and experience that magical moment of uploading your app for Apple&#8217;s approval (followed shortly by that equally magical moment of getting your app rejected cuz BEWBZ.)  Let&#8217;s do it!</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F21%2Fflash-to-ios-a-step-by-step-tutorial-part-5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F21%2Fflash-to-ios-a-step-by-step-tutorial-part-5%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/12/21/flash-to-ios-a-step-by-step-tutorial-part-5/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=4272&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/12/21/flash-to-ios-a-step-by-step-tutorial-part-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash to iOS: A Step-by-Step Tutorial (Part 4)</title>
		<link>http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 21:43:56 +0000</pubDate>
		<dc:creator>Sina Kashanizadeh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=4171</guid>
		<description><![CDATA[This is the fourth part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch. Jump to other parts in the series: Part 1 &#8211; Sign up [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<div class="displayed">
<img src="http://www.untoldentertainment.com/blog/img/2011_12_07/iPadAIR.png" alt="Flash to iOS: A Step-by-Step Tutorial" />
</div>
<p></center></p>
<p>This is the fourth part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch.</p>
<p>Jump to other parts in the series:</p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/" title="Flash to iOS: A Step-by-Step Tutorial (Part 1)"><b>Part 1</b> &#8211; Sign up for an Apple iOS Developer Account</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 2)"><b>Part 2</b> &#8211; Obtain your Signing Certificate &#038; Mobile Provisioning Profile, and create your App ID</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 3)"><b>Part 3</b> -Use FlashDevelop to build your mobile AIR app</a>
</ul>
<p>In this section of the tutorial, the rubber meets the road.  You&#8217;ll make all the finicky adjustments to FlashDevelop and the AIR bundling files to get your Hello Planet app up and running on your testing device.</p>
<h2>Point FlashDevelop to the Merged SDK Folder</h2>
<p>Now that your (cr)app is successfully up and running, you have to make a few tweaks and adjustments to FlashDevelop. You&#8217;ll start by telling FlashDevelop all about that merged SDK folder you created in Part 3. </p>
<ol>
<li>In the Project panel on the right, you&#8217;ll see a file called AIR_iOS_readme.txt. Double click that file to open it.
<p>This txt file lists a number of settings needed to get your ipa file working.  The ipa file is the Holy Grail- the native app file that you&#8217;ll send to your testing device to see everything working properly. A window pops up with a bunch of options.</p>
<li>Click the Project Properties button at the top of the Properties Panel (alternately, you can use the menus to navigate to Project>Properties).
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/projectProperties.jpg" alt="FlashDevelop Project Properties"></p>
</div>
<li>Change the version of your AIR SDK from 2.7 to <b>3.0</b> because (at the time of this writing), that is the latest version.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/projectPropertiesOptions.jpg" alt="FlashDevelop Project Properties Options"></p>
</div>
<li>Click on the SDK tab, and click <b>Manage</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/manage.jpg" alt="FlashDevelop Project Properties Options - Manage"></p>
</div>
<li>On the next screen you will see list of installed Flex SDKs. Click the ellipsis (&#8230;) button at the end of that line.  An <b>InstalledSDK Collection Editor</b> window pops up.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/ellipsis.jpg" alt="FlashDevelop Project Properties Options - Flex SDK Location"></p>
</div>
<li>You&#8217;re going to point FlashDevelop to the location of our recently-downloaded Flex SDK (the same folder that contains both the Flex SDK and AIR SDK  that you created earlier in this tutorial).  First click the <b>Add</b> button, and then click on the <b>Path</b> line to get another ellipsis. Click on THAT ellipsis to browse your computer.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/add.jpg" alt="Add"></p>
</div>
<li>Once you have clicked the ellipsis button, a Windows File Browser appears. Navigate to the merged SDK directory. Select that folder and click <b>OK</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/navigate.jpg" alt="Navigate to your merged SDK folder"></p>
</div>
<li>Click <b>OK</b> again to exit the <b>InstalledSDK Collection Editor</b> window.
<li>Click <b>Close</b>.
<li>In the drop-down menu, you should see the Default option. Click on the drop-down list and choose the SDK location you just told FlashDevelop about.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/dropDown.jpg" alt="Choose your Merged SDK profile from the drop-down menu."></p>
</div>
<li>Click <b>Apply</b>.
<li>Click <b>OK</b>. Voila! Your SDK is now setup for your FlashDevelop Project.
<p>Let’s just test it out quickly to see if it works. The code you pasted in the previous tutorial prints out the words &#8220;Hello Planet&#8221; within your app. Well, I&#8217;m going to change mine to say &#8220;Sina is Cool&#8221;, just because I can, and also because I AM COOL. (You may be tempted to replace &#8220;Sina&#8221; with your own name.  Please don&#8217;t, because uh &#8230; your code won&#8217;t work.)</p>
<p>Your resulting app should look like this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/sinaIsCool.jpg" alt="Breaking: Sina is cool."></p>
</div>
<p>A beautiful sight, isn&#8217;t it?</p>
<p>(At this point, Sina actually is pretty damned cool. &#8211; Ed.)</p>
</ol>
<h2>Delete the Extra Icons Folder</h2>
<p>Now you have FlashDevelop set up to create mobile-formatted AIR apps. Your app compiles, and you have your <b>Mobile Provisioning Profile</b> and your <b>.p12 Signing Certificate</b> waiting in the wings. All you need to do is combine all these amazing files together to create the Holy Grail .ipa file.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/holyGrail.jpg" alt="The .ipa file is the Holy Grail of this tutorial series"></p>
<p>Ah &#8211; this is truly the .ipa of a FlashDeveloper.
</p></div>
<p>An <b>.ipa</b> file is like the program file &#8211; the Windows executable (.exe) &#8211; that you need to test your iPhone/iPad App on a device, and ultimately upload it to the Apple App Store.</p>
<p>The creators of FlashDevelop 4 made a minor error when they created the Mobile App template: the template generates a duplicate <b>icons</b> folder that will cause a conflict when you try to bundle your <b>.ipa</b> file. You need to get rid of this extra folder to make sure your .ipa file to builds properly. </p>
<ol>
<li>Look in the right sidebar that lists your files and folders. You&#8217;ll see a folder called <b>bin</b>.  (This is one of the folders that FlashDevelop created for you automatically when you created your project.)
<li>Click on the little plus sign beside the <b>bin</b> folder to expand it. You will see a folder called <b>icons</b> tucked inside. Right-click the <b>icons</b> folder and click <b>Delete</b>. Problem solved.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/delete.jpg" alt="Delete the icons folder to avoid a conflict later"></p>
</div>
</ol>
<h2>Integrate Your Cert Files</h2>
</ol>
<li>Copy your <b>Mobile Provisioning Profile</b> and your <b>.p12 Signing Certificate</b> into the <b>certs</b> folder of your project. If you&#8217;ve been following along with this tutorial from the beginning, you probably saved these two files in the <b>bin</b> folder of your OpenSSL install.
<p>Once the files are in the right place, they should show up in your Project sidebar:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/certs.jpg" alt="You put yer WEED in there."></p>
</div>
<p>To create the <b>.ipa</b>, you have to edit a couple of lines in a <b>batch file</b> so that the app compiles properly. Don’t be scared: a batch file (.bat) is simply a text file that runs a script when you double-click it in Windows. You can open up a batch file by using a text editor of any kind.  Since you&#8217;ve already got FlashDevelop open, it makes a lot of sense to use it to edit the batch files.</p>
<p>In the following screenshot, I&#8217;ve opened up the ReadMe file that describes the iOS compilation steps. Step 5 talks about editing a batch file. Take a read if you&#8217;re nervous.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/readme.jpg" alt="iOS compilation readme"></p>
</div>
<li>In the sidebar, find the <b>bat</b> folder and expand it.
<li>Double-click the <b>SetupApplication.bat</b> file. The file should open in FlashDevelop.
<li>In the batch file, you should see some green text that says <b>ios packaging</b>, and a bunch of <b>set</b> options beneath it. This is where you have to add or adjust some text. In the IOS_DEV_CERT_FILE line, type the path to your .p12 <b>Signing Certificate</b> file (the one you just copied into the <b>certs</b> folder). You only have to use a <em>relative path</em> (one that describes where the file is in relation to the compilation target), so just copy what I have and you should be fine:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">cert\iphone_dev.p12</pre></div></div>

<li>In the IOS_DEV_CERT_PASS line, you have to enter password that you set when you made your <b>Signing Certificate</b>. (Don&#8217;t come crying to me if you don&#8217;t remember it &#8211; i told you to write it down &#8211; Ed.)
<li>In the IOS_PROVISION line, type the name of your <b>Mobile Provisioning Profile</b>.
<p>All in all your SetupApplication.bat should look like this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/setupApplication.jpg" alt="SetupApplication.bat"></p>
</div>
<p><b>Note:</b> Make sure you have the path properly setup as well as the same exact filename. If you have any sort of typo, it&#8217;s not going to work.
</ol>
<h2>Get Your Ducks in a Row</h2>
<p>You&#8217;re almost there! All you have to do is edit the <b>SetupSDK.bat</b> file.</p>
<ol>
<li>Double-click the <b>SetupSDK.bat</b> file to open it in FlashDevelop.
<li>At the top of the file, you&#8217;ll see a line that says <b>path to Flex SDK</b> in green. Right under that line is the path to the SDK. However, it&#8217;s not pointing to the merged SDK folder that we created earlier. Replace the default path with the path to your merged SDK folder. It might look similar to this:
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/setupSDK.jpg" alt="SetupSDK.bat"></p>
</div>
<p><b>Note:</b> Remember to save often!</p>
<li>Open the <b>application.xml</b> file. This xml file is the descriptor file for your application. You have to double-check to ensure everything in there is correct. Everything from your App name to the version of your App is located in this file.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/applicationXML.jpg" alt="Application.xml"></p>
</div>
<li>Change the version number at the end of the <b>xmlns</b> parameter of the root <b>application</b> node to the version of AIR you&#8217;re running. In this case (and at the time of this writing), it&#8217;s <b>3.0</b>.
<li>In the <b>id</b> node, enter the package name that you created for your <b>Mobile Provisioning Profile</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/applicationXMLChanges.jpg" alt="Application.xml changes"></p>
</div>
<p>If you don’t remember what your Bundle ID was, go to the Provisioning Portal on the <a href="http://developer.apple.com" title="Apple Developer Site">iOS developer website</a> and click on <b>Provisioning</b>.</p>
</ol>
<h2>Compile Time</h2>
<p>After all that, you&#8217;re finally ready to compile your <b>.ipa</b> file to test on an iOS device.</p>
<ol>
<li>In the sidebar, right-click the <b>PackageApp.bat</b> file and select <b>Execute</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/execute.jpg" alt="Execute!"></p>
</div>
<li>You&#8217;ll see a bunch of options. Since this is only a test, you can pick the <b>fast test</b> option. This option will quickly create an <b>.ipa</b> file for you to throw onto your iWhatever. Once you choose <b>fast test</b>, sit back and relax.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/choices.jpg" alt="Choices"></p>
</div>
<li>Look in the <b>dist</b> folder in the sidebar. You now have an <b>.ipa</b> file!
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/success.jpg" alt="Success!"></p>
</div>
</ol>
<h2>Test Your New App</h2>
<p>Take a moment and soak in what you&#8217;ve accomplished. You&#8217;re in the final steps of your epic journey of iEnlightenment. All you have to do now is load the hard-fought <b>.ipa</b> file up on your iWhatever.</p>
<p>I made a copy of my <b>Mobile Provisioning Profile</b> and my <b>.ipa</b> file and put them in a separate folder. I suggest you do the same as a backup measure &#8230; better safe than sorry.  Now let&#8217;s get that sucker onto your device.</p>
<ol>
<li>Plug in your iPhone/iPad/iPod Touch/iEtCetera and let it sync in iTunes.
<li>After it&#8217;s synced, go to <b>Library -> Apps</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/iTunes.jpg" alt="iTunes"></p>
</div>
<li>To add your <b>Mobile Provisioning Profile</b>, click and drag it from your folder into the <b>iTunes Library</b>.
<li>Follow the same process to add your <b>.ipa</b> file.
<p><b>Note:</b> You have to add your <b>Mobile Provisioning Profile</b> before you add your <b>.ipa</b> file! If you add these files in the wrong order, you may get errors!</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/dragAndDrop.jpg" alt="Drag and drop your files into iTunes"></p>
</div>
<p>After dragging your <b>.ipa</b> file into iTunes, you&#8217;ll see a generic App icon that FlashDevelop/AIR generated for you.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/genericIcon.jpg" alt="Generic Apple App Icon"></p>
</div>
<li>In the left sidebar, click on <b>Devices -> Your iPad/iPod/iPhone</b>.
<li>Click on the little <b>Apps</b> button at the top of iTunes. You&#8217;ll see a screen that displays all your Apps. Within that screen, you should be able to find your App (you may have to scroll around a little to find it).
<li>Click the <b>Apply</b> button to transfer everything to your device.
<p>iTunes will go through the syncing process, and will add your App to your device. You can click sync a few more times just to make sure everything is good &#8211; iTunes doesn&#8217;t always behave perfectly on a PC.</p>
<p><b>Note:</b> If you get an error saying that the App failed to install, your <b>Bundle ID</b> or something within your <b>Application.xml</b> may be wrong. Double-check everything! There is no harm in deleting your App and from iTunes and transferring it again. You can also overwrite your <b>Mobile Provision Profile</b> with a corrected one.</p>
<p><b>DOUBLE NOTE:</b> If you change anything in your project, you must compile your <b>.ipa</b> file again, because it contains all the new information necessary for iTunes to run your App.</p>
<li>Fire up your iPad/iPhone and BAM!
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/beautiful.jpg" alt="AIR on iOS"></p>
</div>
<p>It’s so &#8230; beautiful. *sniff*
</ol>
<h2>To the App Store &#8230; and Beyond!</h2>
<p>In this section of the tutorial, you:</p>
<ul>
<li>Pointed FlashDevelop to your merged AIR/Flex SDK folder
<li>Corrected an error with the Mobile AIR template by deleting an extraneous icons folder
<li>Copied your <b>Mobile Provisioning Profile</b> and your <b>.p12 Signing Certificate</b> into your project and pointed FlashDevelop to them
<li>Pointed the SetupSDK.bat file to the merged SDK folder
<li>Modified the application.xml descriptor file to match your project settings
<li>Compiled your project and created an <b>.ipa</b> file
<li>Copied your <b>.ipa</b> file and <b>Mobile Provisioning Profile</b> into iTunes
<li>Synced your app and ran it on your testing device!
</ul>
<p>With your project set up, you can continue developing your application until you have an amazing <em>thing</em> that you&#8217;re ready to foist on the app-buying public. There are still a few more things you need to know to deploy your app to the live iTunes store.  What about that generic AIR icon?  Wouldn&#8217;t you like to see something nicer in its place?  And how do you get your <b>.ipa</b> file in front of the app-approvers at Apple to get it to show up in iTunes?  And are we finished with certificates and profiles, or is there more to do?</p>
<p>Short answer? <em>There&#8217;s more to do.</em>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F14%2Fflash-to-ios-a-step-by-step-tutorial-part-4%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F14%2Fflash-to-ios-a-step-by-step-tutorial-part-4%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=4171&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flash to iOS: A Step-by-Step Tutorial (Part 3)</title>
		<link>http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 16:25:16 +0000</pubDate>
		<dc:creator>Sina Kashanizadeh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=4193</guid>
		<description><![CDATA[This is the third part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch. Jump to other parts in the series: Part 1 &#8211; Sign up [...]]]></description>
			<content:encoded><![CDATA[<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_07/iPadAIR.png" alt="Flash to iOS: A Step-by-Step Tutorial"></p>
</div>
<p>This is the third part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch.</p>
<p>Jump to other parts in the series:</p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/" title="Flash to iOS: A Step-by-Step Tutorial (Part 1)"><b>Part 1</b> &#8211; Sign up for an Apple iOS Developer Account</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 2)"><b>Part 2</b> &#8211; Obtain your Signing Certificate &#038; Mobile Provisioning Profile, and create your App ID</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" title="Flash to iOS: A Step-by-Step Tutorial (Part 4)"><b>Part 4</b> &#8211; Modify your project settings and test your app on an Apple device</a>
</ul>
<h2>Luke Loses His Hand</h2>
<p><a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 2)">Part 2</a> of this tutorial was like <b>The Empire Strikes Back</b>.  It was the crisis moment in the story of deploying a Flash project to the Apple iOS platform.  It was dark, it was difficult, and Han Solo wound up frozen in carbonite.  Part 3 is redemptive: with all that command line and certificate red tape out of the way, you can finally build our AS3 app using FlashDevelop. Watch closely, friends: you may spot some ewoks.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/iPhone.jpg" alt="It's a trap."></p>
<p>It&#8217;s a trap.
</p></div>
<h2>Install Flash Develop</h2>
<p>As I mentioned earlier in the series, FlashDevelop is a FREE, PC-only coding environment that is used throughout the industry and loved by many. If you haven&#8217;t installed it, <a href="http://www.flashdevelop.org/community/viewforum.php?f=11">head here to download the latest version.</a></p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/fd4.jpg" alt="FlashDevelop 4"></p>
</div>
<p>FlashDevelop is an IDE (Integrated Development Environment) where you can create many different types of applications from scratch.  The most amazing thing about FlashDevelop is that you don’t actually need to buy Adobe&#8217;s Flash Professional software to create Flash (swf) content. FlashDevelop has amazing, time-saving features like importing code libraries on the fly, and numerous awesome templates. At the time of this writing, the latest edition of FlashDevelop is 4.0.0. This version of FlashDevelop contains a template for Mobile AIR applications which you can use for iOS and Android development. In this tutorial, you&#8217;ll use the iOS version of the template.</p>
<h2>Create a Merged SDK Folder</h2>
<p>There are two SDKs (Software Development Kits) you&#8217;ll need to deploy Flash content to the iOS platform: Flex and AIR. Depending on the version of FlashDevelop you install, these two SDKs may already be included in the download.  You&#8217;re going to download them both anew and put them in a single folder. That way, if you mess anything up, you can take off and nuke the site from orbit instead of messing up your main FD install.  It&#8217;s the only way.</p>
<ol>
<li><a href="http://www.adobe.com/special/products/air/sdk/thankyou.html?download=win" title="Download Adobe AIR SDK">Download the latest AIR SDK</a> (which, at the time of this writing, was v3.0)
<li><a href="http://opensource.adobe.com/wiki/display/flexsdk/Downloads" title="Download the latest Flex SDK">Download the Flex SDK</a>.
<li>These two packages download as <b>.zip</b> files.  Extract them wherever you like on your computer &#8211; just make sure you know where you put them.
<li>Once you have both SDK&#8217;s extracted to separate folders, copy everything in the AIR SDK folder into the Flex SDK folder. Windows will ask you if you want to overwrite certain files. Say &#8220;yes&#8221; to everything.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/merge.jpg" alt="Merged SDK folder"></p>
</div>
<p>You now have a folder with the <b>Flex SDK</b> and the <b>AIR SDK</b> merged into one. This is a Good Thing™.</p>
</ol>
<h2>Point FlashDevelop to the Flex SDK</h2>
<p>In order to compile (build and execute) your app, you have to point FlashDevelop to the merged SDK folder that you just created.</p>
<ol>
<li>Open up FlashDevelop and hit <b>F10</b> or go to <b>Tools->Program Settings</b> in the menus.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/programSettings.jpg" alt="Program Settings"></p>
</div>
<li>In the Program Settings menu, click on <b>AS3 Context</b>.
<li>Find the <b>Language</b> section, and the <b>Flex SDK Location</b> line within it.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/as3Context.jpg" alt="AS3 Context"></p>
</div>
<li>Click the ellipsis button at the end of that line, and navigate to the merged SDK folder.
<li>Click <b>Close</b> to commit the change.
</ol>
<h2>Set Up Your Mobile AIR Application</h2>
<p>Once you have downloaded and installed FlashDevelop, open it up and you should see it in all its glory:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/fdInterface.jpg" alt="FlashDevelop 4 Interace"></p>
</div>
<p>To begin with, you&#8217;ll need to create a new FlashDevelop project, which is a group of folders governed by a file filled with metadata about your project.</p>
<ol>
<li>Create a new project by clicking <b>Project -> New Project</b> in the menu.
<li>Now you will see a screen with a multitude of options. These are all project starter templates that FlashDevelop has for you to use. The one you want is the <b>AIR Mobile AS3 App</b>. Select this template, choose a location on your hard drive to save it, give a name to your project, and hit OK.
<p>Note: A package name is not required but the option is there if you&#8217;d like to use it.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/fdTemplates.jpg" alt="FlashDevelop 4 Project Templates"></p>
</div>
<p>After you hit OK, FlashDevelop creates a number of folders and files for you, including:</p>
<ul>
<li>The .as3proj file, which is a FlashDevelop project file filled with metadata that keeps track of various aspects of your project.
<li>The <em>bin</em> folder. This is where your finished files end up.
<li>The <em>lib</em> folder, where you can put your &#8220;construction&#8221; files and artwork.
<li>The <em>src</em> folder, which contains your .as AS3 code files.
</ul>
<li>Once you&#8217;ve created your project file, FlashDevelop starts you off with a blank screen. To open up your code, click on the <b>src</b> folder in the Project sidebar on the right. (The Project sidebar lists your computer&#8217;s actual directory structure so that you can access your Actionscript files quickly and easily.)
<li>Inside the <b>src</b> folder, double click the <b>Main.as</b> file to open it. This is your project&#8217;s point of entry, where you can start writing the code for your app.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/main.jpg" alt="FlashDevelop 4 Main.as"></p>
</div>
<li>Push the F5 key on your keyboard, or the click the little play button at the top-middle of FlashDevelop to compile and run your project.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/compile.jpg" alt="FlashDevelop 4 Compile Button"></p>
</div>
<p>The first compile will take little bit of time, but any compile after that should be quick, because the compiler builds on an as-needed basis, compiling only your most recent changes (as opposed to Flash Professional, which compiles your ENTIRE project every single time. Bleh!). Once you run your new project, the FlashPlayer should pop up and you should see a blank screen. Luckily, this is exactly what we want. As of right now, this is your App.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/blankApp.jpg" alt="FlashDevelop 4 Blank App"></p>
</div>
</ol>
<h2>Hello, Planet</h2>
<p>This is nice and all, but let&#8217;s try to the write a simple message on screen so that when we are testing, we know it actually works. Let&#8217;s write &#8220;Hello Planet&#8221; on-screen.</p>
<ol>
<li>Just below the green commented line where it says //entry point in your <b>Main.as</b> file, copy and paste these lines into your code:

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> tf:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;  
<span style="color: #000000; font-weight: bold;">var</span> format:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;  
format.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;_sans&quot;</span>;  
format.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">48</span>;  
tf.<span style="color: #006600;">defaultTextFormat</span> = format;  
tf.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Hello Planet&quot;</span>;  
tf.<span style="color: #0066CC;">width</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span> - <span style="color: #cc66cc;">20</span>;  
tf.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;  
tf.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;  
addChild<span style="color: #66cc66;">&#40;</span>tf<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/entryPoint.jpg" alt="Code Entry Point"></p>
</div>
<li>Click the compile button (or press F5). Did it screw up? Good. There are a couple more things you have to do before you are ready to compile without errors.
<li>In your code, click to place your cursor carat on the word <b>Textfield</b> and hit Ctrl+Shift+1 on your keyboard. The word turns blue. If you scroll to the top of the class, you&#8217;ll notice that there is an extra import line at the top of your code. CTRL+SHIFT+1 is a special feature of FlashDevelop that does code completion. In this instance, CTRL+SHIFT+1 automatically handles your import statements for you.  You need to import the TextField code with this statement if you want your TextField to work.
<li>Use CTRL+SHIFT+1 on the <b>TextFormat</b> word and you should see this:
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/imports.jpg" alt="Import Statements"></p>
</div>
<li>Now click Compile (or press F5).
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_03/helloPlanet.jpg" alt="Hello Planet"></p>
<p>Thar she blows!
</p></div>
<p>(It works, but it&#8217;s no Angry Birds. &#8211; Ed.)
</ol>
<h2>Bust Out the Hardware</h2>
<p>This is moving along nicely.  You:</p>
<ul>
<li>Installed FlashDevelop, a free and open-source IDE for creating Flash and AIR content
<li>Downloaded and sunk the latest AIR SDK and Flex SDK into a single, merged folder
<li>Pointed FlashDevelop to the Flex SDK to use its superior compiler
<li>Created a new FlashDevelop project using the Mobile AIR application template
<li>Wrote and compiled a new Hello Planet AIR app that you can deploy to a testing device
</ul>
<p>In the next part of the tutorial, you&#8217;ll fine-tune FlashDevelop and modify a number of settings and batch files to create the magical, mystical <b>.ipa</b> file, and you&#8217;ll see that file running on your testing device.<br />
</a></p>
<p><a href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" title="Flash to iOS: A Step-by-Step Tutorial (Part 4)">Continue to <b>Part 4</b></a>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F07%2Fflash-to-ios-a-step-by-step-tutorial-part-3-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F12%2F07%2Fflash-to-ios-a-step-by-step-tutorial-part-3-2%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=4193&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Flash to iOS: A Step-by-Step Tutorial (Part 2)</title>
		<link>http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 15:09:49 +0000</pubDate>
		<dc:creator>Sina Kashanizadeh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=4097</guid>
		<description><![CDATA[This is the second part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch. Jump to other parts in the series: Part 1 &#8211; Sign up [...]]]></description>
			<content:encoded><![CDATA[<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_07/iPadAIR.png" alt="Flash to iOS: A Step-by-Step Tutorial"></p>
</div>
<p>This is the second part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch.</p>
<p>Jump to other parts in the series:</p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/" title="Flash to iOS: A Step-by-Step Tutorial (Part 1)"><b>Part 1</b> &#8211; Sign up for an Apple iOS Developer Account</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 3)"><b>Part 3</b> -Use FlashDevelop to build your mobile AIR app</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" title="Flash to iOS: A Step-by-Step Tutorial (Part 4)"><b>Part 4</b> &#8211; Modify your project settings and test your app on an Apple device</a>
</ul>
<h2>Drudgery</h2>
<p>Without a doubt, this section of our tutorial series on bundling your Adobe AIR App for Apple&#8217;s iOS platform is the pits.  You have to use a complicated command line interpreter, you have to juggle what may feel like a million different certificates and profiles, and you have to jump through a dizzying array of hoops just to get everything set up &#8230; and you&#8217;re not even going to <em>start</em> building your app at all!  But trust me: once you&#8217;ve cleared these hurdles, the rest of the process is gravy. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/gravy.jpg" alt="Gravy"></p>
<p>Thick, delicious gravy.
</p></div>
<p>The first goal of this tutorial is to create a <em>signing certificate</em>, which is used very much like a hot brand on cattle. It&#8217;s the digital signature of you or your company that identifies an app as your own. We need to use a program called OpenSSL to create this signing certificate.</p>
<h2>Install Open SSL</h2>
<p>In order to turn your future AIR project into a native app, you need to create two important files: a Signing Certificate and a Mobile Provisioning Profile. If you are working on a Mac, you actually use a program called Keychain to do some fancy voodoo magic and get the certificate you need.  We are working on a PC and we do not have that luxury, so there are a couple of confusing steps that we must go through. </p>
<p>The first thing you have to do is go to <a href="http://www.slproweb.com/products/Win32OpenSSL.html">http://www.slproweb.com/products/Win32OpenSSL.html</a>. Scroll down, and then download the Visual C++ 2008 Redistributables and install the resulting file. Next, download the <b>Win32 OpenSSL v1.0a Light</b> file and install that after you have installed the first package. These two files will help you create the Signing Certificate Request you so richly deserve.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/openSSL.jpg" alt="OpenSSL"></p>
</div>
<p>Be sure to keep track of where you installed those last two elements. Next, visit this site:</p>
<p><a href="http://help.adobe.com/en_US/as3/iphone/index.html">http://help.adobe.com/en_US/as3/iphone/index.html</a>.</p>
<p>These are Adobe&#8217;s help files for generating your signing certificate and then converting that certificate into a .P12 file. If you get lost in this tutorial, that page will be your safety net.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/adobeHelpPage.jpg" alt="Adobe Help Page"></p>
</div>
<p>On that Adobe support page, you will see some instructions for Mac machines. Ignore them.  Scroll down to the Windows instructions and give them a once-over.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/instructions.jpg" alt="Instructions"></p>
</div>
<p>The instructions say that you have to install Open SSL. You&#8217;ve already done that. Open a command prompt window. You can do this by going to your <b>Start</b> button and typing in cmd in the search field.  (You can also hold the Windows key on your keyboard and hit the &#8220;R&#8221; key (for &#8220;Run&#8221;), then type <b>cmd</b> and hit Enter.)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/cmd.jpg" alt="CMD"></p>
</div>
<p>Once you are in the command prompt, travel your way to your Open SSL bin folder. Depending on where you installed it you will have to travel to a different path than in this example.  (For your sake, i hope you installed Open SSL in a location that you can remember!) </p>
<p>If this is your first time using the command prompt, here&#8217;s a quick primer on the commands that will help you get around:</p>
<ul>
<li><b>cd</b> This command means &#8220;Change Directory&#8221;. If you are in a directory and you want to go into one of its sub-directories, use this command plus the directory name (example: cd directoryName)
<li><b>cd..</b> This command will pull you up one level in your directory structure
<li><b>dir</b> Type this command to see a list of all of the files and folders within your current directory
<li><b>dir /w</b> The /w (wide) switch spreads a directory listing across multiple columns.  This is useful for seeing all the folder names at a glance, instead of in one big long scrolling list.
</ul>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/cd.jpg" alt="CLI Commands"></p>
</div>
<p>You may have some problems getting some of the following commands to work. A fine commenter (and Ontario resident!) named Dan Zen mentioned on the Adobe guide&#8217;s comments section that you may need to input <b>set RANDFILE=.rnd</b> in your command prompt before the following commands will work properly.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/randfile.jpg" alt="RANDFILE command"></p>
</div>
<h2>Generate a Signing Certificate Request File</h2>
<p>With all of that taken care of, you can start inputting some commands to create your Signing Certificate Request file.  Once you have that file, you&#8217;ll use it to ask Apple for your proper Signing Certificate file that you&#8217;ll use to identify your app. </p>
<ol>
<li> Punch this command into your command line interpreter and hit the ENTER key when you&#8217;re finished:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl genrsa -out mykey.key 2048</pre></div></div>

<p>You should see this response:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/response.jpg" alt="response"></p>
</div>
<li>Next, type (or highlight the line, right-click, choose &#8220;Copy&#8221;, and right-click/&#8221;Paste&#8221; in the command line interpreter):

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest  -subj &quot;/emailAddress=yourAddress<span style="color: #33cc33;">@</span>example.com, CN=John Doe, C=US&quot;</pre></div></div>

<li>Now, before you hit ENTER you&#8217;ll want to edit a couple of things. First, replace &#8220;John Doe&#8221; with your own name or company name. Then replace the &#8220;yourAddress@example.com&#8221; email with your own email. Then press ENTER.
<p>You should get a message similar to this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/response2.jpg" alt="response"></p>
</div>
<p>You just generated the Signing Certificate Request file that you&#8217;ll use to ask Apple for your Signing Certificate. The  Signing Certificate Request file is located in the <em>bin</em> folder of your Open SSL install.  It has a <em>.certSigningRequest</em> file extension and should look like this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/signingRequest.jpg" alt="Certificate Signing Request file"></p>
</div>
</ol>
<h2>Obtain a Signing Certificate for Development</h2>
<p>You have to upload your Signing Certificate Request file to the Apple Provisioning Portal to get your signing certificate.</p>
<p>Note: There have been instances where this upload does not work with Google Chrome. Just to be safe, use another browser like Firefox.</p>
<ol>
<li>Navigate to the iOS Provisioning Portal after logging in with your <a href="http://developer.apple.com">developer account</a> and click on <b>Certificates</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/certificates.jpg" alt="Certificates"></p>
</div>
<li>Click <b>Request Certificate</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/requestCertificate.jpg" alt="Request Certificate"></p>
</div>
<p>Note: If you are a team member and/or you have not paid the annual developer fee of $99 dollars, then you cannot request a Signing Certificate. Only the Team Admin &#8211; the person who has paid the development fee &#8211; will be able make this request.</p>
<p>On the next screen, you will upload the Signing Certificate Request file that you generated in the previous section.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/generateCertificate.jpg" alt="Generate Certificate"></p>
</div>
<li>Click the <b>Browse</b> button and navigate to the <b>bin</b> folder located within your OpenSSL folder.
<li>Once you have selected the Signing Certificate Request file, click Submit. Your next screen should show this:
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/pending.jpg" alt="Certificate Pending"></p>
</div>
<li>Just hit <em>Refresh</em> a couple of times on your browser and you should eventually see this:
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/certificateReady.jpg" alt="Certificate Ready"></p>
</div>
<li>It&#8217;s your Signing Certificate! Go ahead and download it. Just to make things easier, you can save that certificate in the <b>bin</b> folder in the Open SSL folder, where your Certificate Signing Request file is sitting.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/saveCertificate.jpg" alt="Save Certificate"></p>
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/saveCertificate2.jpg" alt="Save Certificate 2"></p>
</div>
<h2>Convert the Signing Certificate to a .p12 File</h2>
<p>Are you having fun yet? Yeah, me neither. We are making good progress though. The next step is converting that Signing Certificate to a p12 certificate, because <em>Apple loves certificates</em>.</p>
<ol>
<li>From the Adobe help page, visit the link describing the process of <a href="http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-7fff.html">converting a developer certificate to a p12 file</a>. You get a list of more commands that you&#8217;ll have to punch into your trusty old command prompt.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/helpPage2.jpg" alt="Adobe Help Page 2"></p>
</div>
<li>Copy the first command (highlight the text, right-click and select &#8220;Copy&#8221; from the context menu):

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM</pre></div></div>

<li>Open up your command prompt as I showed earlier, and navigate to the <b>bin</b> folder of your Open SSL directory.
<li>Once you&#8217;re there, paste in the first command (right-click and select &#8220;Paste&#8221; from the context menu), and press ENTER.
<li>Skip ahead to Step 3 of the Adobe help guide and copy that command. (The command in Step 2 is for Macs only.)

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12</pre></div></div>

<li>Once you punch in the command, enter a password and then verify that password. Make sure the password is something that you will remember.  (Save it in a .txt file in that folder if you&#8217;ve got a lousy memory like me &#8211; Ed.) When you are typing in your password, the command prompt does not give you the luxury of seeing dots or asterisks to indicate how many letters you are typing in. Rest assured that the command is accepting your input.
<p>Note: You <em>may</em> get an error mentioning a &#8220;random state&#8221;. Just type in the command <b>set RANDFILE=.rnd</b> and it should fix the problem for you.</p>
<li>Go into the <b>bin</b> folder in your Open SSL directory and you should see your .p12 file.  Hooray!
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/p12file.jpg" alt="p12 Signing Certificate"></p>
</div>
</ol>
<h2>Create an App ID</h2>
<p>Now that you have the precious file you need, it&#8217;s finally time to create your Mobile Provisioning Profile.  You&#8217;ll start by setting up a unique ID for the app you&#8217;re creating.</p>
<ol>
<li>Navigate back to the <b>Provisioning Portal</b> in your web browser to create an App ID for your app. <a href="http://developer.apple.com" title="Apple Developer Portal">Log in</a>, click on <b>Provisioning Portal</b>, and click on <b>App IDs</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/appIDs.jpg" alt="App IDs"></p>
</div>
<li>Click <b>New App ID</b>.
<p>Note: If you have not paid the developer fee, or if you are just a team member of the Team Admin, you will not see this option. Ask your Team Admin to complete this step.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/newAppID.jpg" alt="New App ID"></p>
</div>
<li>On the next screen you&#8217;ll start by writing a Description for your app, which can be anything you want. (This is what the player will see when he sees your app in the App Store. Obviously, there&#8217;s a whole marketing concern here that&#8217;s outside the scope of this tutorial.  Since we&#8217;re just building a test app, i recommend you punch SOME CRAZY NONSENSE in there for your description.  Take THAT, marketing.  -Ed)
<p>Within the <b>Bundle Seed ID (App ID Prefix)</b> you will have various options, depending on your account status. If you are the Team Admin, you&#8217;ll have a &#8220;Generate New&#8221; option. Team Members will only see a &#8220;Use Team ID&#8221; option.  (If this is not your first App, you could also choose the Bundle Seed IDs for previous project). Either way, leave it at the default.</p>
<p>The <b>Bundle Identifier</b> lets you create a specific package for your App. The standard way to make this package is to reverse the name of your website domain. I used com.sina.ipadtest. (Our team uses com.untoldentertainment.whatever &#8211; Ed.)</p>
<p>Alternately, you can use a generic Bundle Identifier by just putting an &#8220;*&#8221; in the field.</p>
<p><b>Note:</b> There have been cases where the asterisk does not work for some people. It is a safe bet you make a specific namespace like the examples above.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/appDescription.jpg" alt="App Description"></p>
</div>
<li>Click <b>Submit</b>.
<p>Voila &#8211; you have now created your App ID! On the next screen you will see all of the app profiles you&#8217;ve created. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/appIDResults.jpg" alt="App ID Results"></p>
</div>
</ol>
<h2>Create a Mobile Provisioning Profile</h2>
<p>Now that you have an <b>App ID</b>, you can now create your <b>Mobile Provisioning Profile</b>.  This is the crowning touch to everything we&#8217;ve done in this tutorial so far. The Mobile Provisioning Profile glues your developer(s), your Signing Certificate, your app ID and your testing device together.  Once you have this file, you&#8217;ll be able to test an app on your device.  </p>
<ol>
<li>Within the Provisioning Portal website, click <b>Provisioning</b> in the sidebar.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/provisioningPortal.jpg" alt="Apple Provisioning Portal"></p>
</div>
<li>Click on <b>New Profile.</b>
<p>Note: You only see this option if you are the fee-paying Team Admin.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/newProfile.jpg" alt="New Apple Provisioning Portal"></p>
</div>
<li>Give your provisioning profile a <b>Profile Name</b>.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/nameProfile.jpg" alt="Apple Name Your Provisioning Profile"></p>
</div>
<li>Choose the <b>Signing Certificate(s)</b> that you want to use with this profile.
<li>Use the drop-down list to indicate the app for which you&#8217;re creating this profile.
<li>Finally, indicate the testing device you want to test it on.
<li>Click Submit.
</ol>
<p>You&#8217;ll be taken to a screen that says your Mobile Provisioning Profile is pending. Just click your browser&#8217;s refresh button a couple of times until the <b>Download</b>button appears, and download your precious, hard-fought profile. Make sure to save it in a location you&#8217;re likely to remember.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_29/profilePending.jpg" alt="Apple Provisioning Profile"></p>
</div>
<h2>Are We There Yet?</h2>
<p>That was a big pile of hoops to jump through just to test an app on your device, and we haven&#8217;t even begun building the app yet!  Here&#8217;s what you just accomplished:</p>
<ol>
<li>You used the command line and OpenSSL to create a Certificate Signing Request file.
<li>You sent that file to Apple. Apple responded by enabling you to download your Signing Certificate file. This file identifies you as the developer of your app.
<li>You converted your Signing Certificate to the .p12 format.
<li>You created an ID for your app.
<li>You created your Mobile Provisioning Profile, the glue that holds all these elements together and enables you to test your app on an iOS device.
</ol>
<p>The good news is that you DO NOT need to repeat the steps to create your Signing Certificate for additional apps. Now that you have that file, you&#8217;ll use it to sign all of your iOS apps from here on in. Similarly, you won&#8217;t have to re-enter your developer ID or device ID for future projects (unless, of course, you gain a new team member or device). The App ID and Mobile Provisioning Profile are the two pieces that are unique to your app &#8211; you WILL need to repeat those steps for additional projects.  </p>
<p>The next part of this tutorial series will cover the process of creating your actual Adobe AIR app using FlashDevelop, bundling it up with this mess of certificates and profiles you just built, and deploying the app to your testing device.  </p>
<p><a href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 3)">Continue to Part 3</a></p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F11%2F30%2Fflash-to-ios-a-step-by-step-tutorial-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F11%2F30%2Fflash-to-ios-a-step-by-step-tutorial-part-2%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=4097&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flash to iOS: A Step-by-Step Tutorial (Part 1)</title>
		<link>http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 15:33:33 +0000</pubDate>
		<dc:creator>Sina Kashanizadeh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod Touch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=4087</guid>
		<description><![CDATA[This is the first part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch. Jump to other parts in the series: Part 2 &#8211; Obtain your [...]]]></description>
			<content:encoded><![CDATA[<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_12_07/iPadAIR.png" alt="Flash to iOS: A Step-by-Step Tutorial" /></p>
</div>
<p>This is the first part of our tutorial series by Intern Sina on creating an AIR application for free on a PC using FlashDevelop, and deploying it as a native app on an iOS device like the Apple iPad, iPhone or iPod Touch.</p>
<p>Jump to other parts in the series:</p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 2)"><b>Part 2</b> &#8211; Obtain your Signing Certificate &#038; Mobile Provisioning Profile, and create your App ID</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/07/flash-to-ios-a-step-by-step-tutorial-part-3-2/" title="Flash to iOS: A Step-by-Step Tutorial (Part 3)"><b>Part 3</b> -Use FlashDevelop to build your mobile AIR app</a>
<li><a href="http://www.untoldentertainment.com/blog/2011/12/14/flash-to-ios-a-step-by-step-tutorial-part-4/" title="Flash to iOS: A Step-by-Step Tutorial (Part 4)"><b>Part 4</b> &#8211; Modify your project settings and test your app on an Apple device</a>
</ul>
<h2>Dead Wrong</h2>
<p>There&#8217;s a lot of <a href="http://en.wikipedia.org/wiki/Fear,_uncertainty_and_doubt">FUD</a> floating around about Flash these days. Ever since Steve Jobs took to the mic and sounded the death knell of at least the <em>perception</em> of Flash, there&#8217;s been heaping gobs of misinformation about what you can and can&#8217;t, should and shouldn&#8217;t do with Flash. i chalk it up to the fact that death is news. It&#8217;s BIG news when Michael Jackson dies, BIG news when Steve Jobs dies, and equally big news if you can be among the first to report on the death of a technology or company &#8211; RIM, Flash, Palm, HP &#8211; take your pick. If it bleeds, it leads.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/tombstone.jpg" alt="Saying stuff is dead is dead" /></p>
<p>Saying stuff is dead, is dead. You heard it here first.</p>
</div>
<p>This hyperbolic and sensational misreporting is particularly damaging for those of us who have made our living developing with Flash and Actionscript. Back in 2000, when i first got into Flash, i chose it because the alternative was HTML. HTML appeared and performed <em>completely differently</em> depending on a number of different factors:</p>
<ol>
<li>The platform (Mac, PC or Linux)</li>
<li>The screen resolution (640&#215;480, 800&#215;600, 1024&#215;768, etc)</li>
<li>The browser (Netscape, Internet Explorer, Safari)</li>
<li>The browser <em>version</em> (HTML could render completely differently from IE6 to IE7)</li>
</ol>
<p>Meanwhile with Flash, i could build something inside the little Flash Player box, and it would look and behave reasonably identically across platforms, resolutions, browsers, and browser versions. (Subsequent versions of the Flash player complicated things a smidge, but we were still WORLDS away from the pain of HTML). What&#8217;s more, as a visual person, i could actually lay things out within the tool, instead of coding them abstractly and waiting to see how the browser would render them. If i wanted something to appear <em>over there</em>, i picked it up and put it <em>over there</em>. No futzing around with padding or align tags for hours.</p>
<p>The push towards HTML5 doesn&#8217;t scare me &#8211; more accurately, it makes me feel ill. It&#8217;s a step backwards. Without proper tooling, i see myself banging my head against the wall picturing absolutely everything in <em>codespace</em> (rather than concretely laid out in front of me in <em>designspace</em>), and programming all kinds of exception cases so that my content performs properly depending on platform, browser and version. You know what? No thanks.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/butterChurn.jpg" alt="Butter Churn" /></p>
<p>Thank God Flash is dead! Now we can finally move forward.</p>
</div>
<h2>Prying Flash from my Cold, Dead Hands</h2>
<p>As long as the tools for other technologies stink, and as long as i can keep making and monetizing projects in Flash, i&#8217;m going to stay the course until there&#8217;s a compelling technological /creative/workflow reason to make a jump. Untold Entertainment has deployed two games <em>written in Actionscript</em> (<strong><a title="Sissy's Magical Ponycorn Adventure on the Apple iPad" href="http://click.linksynergy.com/fs-bin/click?id=S5athXGL5Y4&amp;subid=&amp;offerid=146261.1&amp;type=10&amp;tmpid=3909&amp;RD_PARM1=http%3A%2F%2Fitunes.apple.com%2Fca%2Fapp%2Fsissys-magical-ponycorn-adventure%2Fid445696590%3Fmt%3D8">Sissy&#8217;s Magical Ponycorn Adventure</a></strong> and <strong><a title="Untold Entertainment's Heads on the BlackBerry App Store" href="https://appworld.blackberry.com/webstore/content/reviews/38777?lang=en">Heads</a></strong>) across two different mobile platforms (Apple iPad and the BlackBerry Playbook), and we&#8217;re just getting warmed up.</p>
<p>Here are the facts, at the time of this writing:</p>
<ol>
<li>No one really wants to play a game in a browser on a phone. Native apps are where it&#8217;s at.</li>
<li>Yes, you CAN put Flash- and Actionscript-created content on an iPhone, in native app format.</li>
<li>You can even do it without having to buy Flash Professional or Creative Suite.</li>
<li>You can develop entirely on a PC until the very last step (uploading content to the App Store).</li>
<li>Untold Entertainment is about to show you how.</li>
</ol>
<h2>What You&#8217;ll Need</h2>
<p>While buying Adobe&#8217;s tools is optional, you&#8217;ll still need to spend a bit of money (or mug the right people) to pull this off. Here&#8217;s what you&#8217;ll need:</p>
<ol>
<li>An Apple Developer account, which is $99 USD/year. Once you start down this path, you&#8217;re in it for the long haul &#8230; if you let your developer account lapse, they pull all your products off the store. For realsies.</li>
<li>A Mac (not free) running the latest version of Xcode (free).</li>
<li>An iOS device (optional, but obviously recommended).</li>
<li>FlashDevelop v4 or better (free, PC-only)</li>
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/mac.jpg" alt="Macs are not free" /></p>
<p>A Mac: not free.</p>
</div>
<h2>Introducing Sina</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/pop.jpg" alt="Sina looks like Prince of Persia" /></p>
<p>He&#8217;s the spitting image of this guy &#8211; i swear.</p>
</div>
<p><a href="http://twitter.com/#!/sinakash">Sina Kashanizadeh</a> is a Sheridan College computer programming student and an intern here at Untold Entertainment. He&#8217;s done all the legwork in this process, and has written this step-by-step guiding on porting your Actionscript projects to iOS. Take it away, Sina!</p>
<h2>Flash on iOS? So You Want to Be a Hero&#8230;</h2>
<p>With the mobile world expanding at a crazy rate you may have had the crazy idea to try making an App yourself and putting it on the iPhone. Well, you&#8217;re a brave soul, because it can be a confusing task. This is why I have scoured the internet and composed a step by step tutorial of this process. This tutorial would not have been possible without the fantastic people that maintain <a href="http://www.flashdevelop.org">FlashDevelop</a> and the wonderful community behind it. I would also like to thank <a href="http://www.gotoandlearn.com">Lee Brimelow</a> and <a href="http://seaships.in">Adobe</a> for putting out some great tutorial videos that helped me out a lot. Last but not least, I would like to thank <a href="http://www.CodeandVisual.com">CodeandVisual.com</a> for putting up a fantastic comprehensive guide that inspired me to move forward whenever I had trouble writing this tutorial.</p>
<p>I just want to be clear that this tutorial is not the &#8220;be-all, end-all&#8221; of this process. There are many different ways of transferring your Flash App to iOS, and the problems I cover are specific to my method. Also, the process I cover is PC-specific.</p>
<h2>Getting Started</h2>
<p>Before we begin, I would like to recommend a <a href="http://www.gotoandlearn.com/play.php?id=133">very good video resource</a> by Adobe Evangelist Lee Brimelow, in which he explains the basics of adding an app to the App Store when using Flash. If you do not know how this process works, I highly recommend this video, as it breaks down the somewhat painful process of adding an AIR App to the App Store when using a PC (thanks again, Lee!). The good news is that if you go through this once, you&#8217;ll understand the ins and outs of the process. You only have to do the most painful parts once.</p>
<p>The video covers a myriad of stuff but the basics boil down to this: Your end goal is to create an .ipa file, which is what you&#8217;ll upload to the App Store. To do this you will require:</p>
<ul>
<li>An App</li>
<li>An iOS developer ID from Apple ($)</li>
<li>An iPad or iPhone ($)</li>
<li>A Mac ($, but required for one step only &#8230; borrow one from a friend!)</li>
<li>A Signing Certificate</li>
<li>A Mobile Provisioning Profile</li>
<li>YOUR SOUL</li>
</ul>
<p>Sounds like fun? Well it isn’t, but let’s get cracking anyway!</p>
<h2>Any Club that would Have Me as a Member</h2>
<p>As I mentioned above, you&#8217;ll need a developer ID from Apple. Head over to the <a href="http://developer.apple.com/devcenter/ios/index.action">iOS Dev Center</a> and register for &#8220;free&#8221;.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/lie.jpg" alt="It ain't free" /></p>
<p>&#8220;Free&#8221; as in &#8220;Free Beer &#8230; that you have to pay for.&#8221;</p>
</div>
<p>Go through the steps of signing up and the email verification and you will acquire an Apple ID. Now, the unfortunate thing is that you get the Apple ID for free, but if you want to develop anything with it on a device &#8211; even a silly test app that you will never release &#8211; you will have to pay $99 a year. You&#8217;d better be positive that your <strong>Angry Birds</strong> clone will be worth at least a hundred bucks a year in revenue. You can sign up for a free student account, but again you can’t really do anything with it unless you drop some cash. If you are helping someone develop an App for the iPhone/iPad and they are paying the developer fee, they can add you as a partner to their project.</p>
<h2>Adding a Device to Your Developer Account</h2>
<p>If you want to test and ultimately launch this App, you will need an Apple device such as an iPhone, iPod Touch or iPad. You will also need to register your Apple device with your Apple ID. Follow these steps:</p>
<ol>
<li>Go into the iOS Developer website and log in with your new account info. Here, you will see the iOS Provisioning Portal. Click on it to see further options.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/provisioningPortal.jpg" alt="iOS Provisioning Portal" /></p>
</div>
</li>
<li>click Devices in the sidebar.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/devices.jpg" alt="iOS Devices menu" /></p>
</div>
</li>
<li>Click Add Devices.Note: if you are a partner developer with a team member profile, you will not be able to add a device. The option will only appear for the master account holder.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/addDevices.jpg" alt="iOS Add Devices" /></p>
</div>
</li>
<li>On this screen, you can add up to 100 devices to your account. Start off by adding your Device Name. Nothing fancy here &#8211; just enter something that will help you identify it &#8211; ie &#8220;Sina&#8217;s iPad&#8221;, or &#8220;iPhone what i stole from that guy that one time&#8221;.</li>
<li>Enter the Device ID (40 hex characters). This is the serial number that is associated with the device that you are trying to register. To find this Device ID, open iTunes while your device is connected. On the main screen, you will see all the information about your device, including a field called Serial Number. It doesn&#8217;t look clickable, but click on that field anyway and the number changes to a hex code. That&#8217;s your device ID.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_11_21/deviceID.jpg" alt="iOS Device ID" /></p>
</div>
</li>
<li>Once you&#8217;ve filled in those details, click Submit and the device will be added to your Developer account. Now you can build an Adobe AIR application and test it on your device.The next tutorial will take you through the process of requesting and creating a Signing Certificate, converting that certificate to the p12 format that Apple requires, and generating a Mobile Provisioning Profile for your new app.
<p><a title="Flash to iOS: A Step-by-Step Tutorial (Part 2)" href="http://www.untoldentertainment.com/blog/2011/11/30/flash-to-ios-a-step-by-step-tutorial-part-2/">Continue to Part 2</a></li>
</ol>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F11%2F23%2Fflash-to-ios-a-step-by-step-tutorial-part-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F11%2F23%2Fflash-to-ios-a-step-by-step-tutorial-part-1%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=4087&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/11/23/flash-to-ios-a-step-by-step-tutorial-part-1/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Unity Game Development by Example gets an Update!</title>
		<link>http://www.untoldentertainment.com/blog/2011/10/12/unity-game-development-by-example-gets-an-update/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/10/12/unity-game-development-by-example-gets-an-update/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 14:49:11 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3976</guid>
		<description><![CDATA[Last week, Packt Publishing released the second edition of my seminal and important work, Unity 3.x Game Development by Example: A Beginner&#8217;s Guide, which helps fledgling game developers learn Unity through a serious of bad puns and dick jokes. What&#8217;s New in Version 2? Absolutely nothing! The Unity 3.x version is identical to the first [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, Packt Publishing released the second edition of my seminal and important work, <a href="http://www.amazon.com/gp/product/1849691843/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=untoldentert-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399373&#038;creativeASIN=1849691843"><b>Unity 3.x Game Development by Example: A Beginner&#8217;s Guide</b></a><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=1849691843&#038;camp=217145&#038;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, which helps fledgling game developers learn Unity through a serious of bad puns and dick jokes.</p>
<div class="displayed">
<p><a href="http://www.amazon.com/gp/product/1849691843/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=untoldentert-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399373&#038;creativeASIN=1849691843"><img src="http://www.untoldentertainment.com/blog/img/projects/unity3DByExample/unity3XByExample.jpg" alt="Unity 3.x Game Development by Example"></a><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=1849691843&#038;camp=217145&#038;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
</div>
<h2>What&#8217;s New in Version 2?</h2>
<p>Absolutely nothing!  The Unity 3.x version is identical to the first edition, save for the fancy new cover by UbiSoft Toronto game artist <a href="http://dancoxart.com/" title="Dan Cox Art">Dan Cox</a>.  The occasional errata from the first edition have been corrected, and the screenshots have been updated so that they match Unity&#8217;s subtle interface changes.  i&#8217;ve included two new spaceship models by Dan in Chapter 11 (the same ones you see on the cover), which i&#8217;ll make available to owners of all versions.</p>
<p>The first chapter was updated to discuss the BootCamp demo instead of the original Island Demo, which stopped working reliably as of version 3.  Then, just as we were ready to release the book, Unity launched v3.4, which included <em>yet another</em> demo and more subtle UI changes. So Unity 3.x Game Development by Example has been lovingly (?) re-written TWICE to bring it in-line with what those nutty funsters at Unity have been up to.</p>
<h2>Should i Buy It?</h2>
<p>Yes you should.</p>
<p>i made the rather bold claim that the first edition of the book may very well cure cancer.  i realize now that this was entirely irresponsible of me, and i regret my error in judgment.  i can say now with all certainty that version two is <em>guaranteed</em> to cure cancer, or your money back.  Please contact Pack Publishing for all refund inquiries, including a post mortem certificate from your next of kin.</p>
<h2>Praise for Unity 3D Game Development by Example (from actual people)</h2>
<blockquote><p>&#8220;A great resource for learning Unity.&#8221; &#8211; <a href="http://spyeart.com/">Michael Todd</a>, indie game developer</p></blockquote>
<blockquote><p>&#8220;Creighton&#8217;s book teaches both Unity and good design practices while staying hip, funny, and even controversial. A must read!&#8221; &#8211; <a href="http://www.linkedin.com/pub/ryon-levitt/4/544/534">Ryon Levitt</a>, Game Designer</p></blockquote>
<blockquote><p>&#8220;I went from unemployed to working full-time in California!&#8221; &#8211; <a href="http://mohdsahaf.blogspot.com/">Mohammed Al-Sahaf</a>, game school graduate</p></blockquote>
<blockquote><p>&#8220;I didn&#8217;t loose brain cells when I read this book.&#8221; &#8211; <a href="http://tutorialsbyibrent.com">Brent Arnold</a>, Mobile Developer</p></blockquote>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F10%2F12%2Funity-game-development-by-example-gets-an-update%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F10%2F12%2Funity-game-development-by-example-gets-an-update%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/10/12/unity-game-development-by-example-gets-an-update/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3976&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/10/12/unity-game-development-by-example-gets-an-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Little Things Escalate</title>
		<link>http://www.untoldentertainment.com/blog/2011/08/22/how-little-things-escalate/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/08/22/how-little-things-escalate/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 14:09:44 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3910</guid>
		<description><![CDATA[&#8220;Escalation&#8221; is the term game developers use to describe the ways in which a video game gets progressively more challenging. There are many different ways to escalate a game. Here are a few: decrease the amount of time the player has to complete a goal at the climax of Super Metroid, the player has to [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Escalation&#8221; is the term game developers use to describe the ways in which a video game gets progressively more challenging.  There are many different ways to escalate a game.  Here are a few:</p>
<ol>
<li>decrease the amount of time the player has to complete a goal
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/superMetroid.png" alt="Super Metroid"></p>
<p>at the climax of <b>Super Metroid</b>, the player has to escape the ship before it explodes
</div>
<li>increase the speed or power of obstacles
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/pacMan.jpg" alt="Pac Man"></p>
<p>Pac Man&#8217;s ghost enemies speed up as the game escalates
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/bubbleBobble.jpg" alt="Bubble Bobble"></p>
<p>Bubble Bobble introduces the invincible Baron von Blubba when the player dawdles
</p></div>
<li>decrease the number of &#8220;chances&#8221; or &#8220;tries&#8221; the player has to complete a goal
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/donkeyKong.jpg" alt="Donkey Kong"></p>
<p>Donkey Kong gives the player a set number of tries (&#8220;lives&#8221;) as the game escalates before the machine requires another quarter and the player has to start from the beginning
</p></div>
<li>increase complexity
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/bejeweled.jpg" alt="Bejeweled"></p>
<p>as Bejewelled escalates, it introduces extra gem colours, which makes finding matches more challenging
</p></div>
<li>increase the grind &#8211; an action the player must perform repeatedly to be successful
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/granTurismo.jpg" alt="Gran Turismo"></p>
<p>Gran Turismo introduces endurance races where the player must race for a set number of real-time hours to win
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/worldOfWarcraft.jpg" alt="World of Warcraft"></p>
<p>World of Warcraft confronts the player with increasingly more difficult monsters, which forces the player to repeatedly kill weaker monsters to improve his stats
</p></div>
<li>decrease the amount of visual information available to the player
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/legendOfZelda.jpg" alt="The Legend of Zelda"></p>
<p>The Legend of Zelda periodically turns out the lights, and requires the player to doggedly re-ignite lamps
</p></div>
<li>increase the quota &#8211; the number of small goals the player must complete within the time limit.  This is really just a variation on decreasing the time limit.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/dinerDash.jpg" alt="Diner Dash"></p>
<p>As each level progesses, Diner Dash increases the number of customers you have to serve
</p></div>
</ol>
<h2>Lightning Bolt!  Lightning Bolt!</h2>
<p>i learned an interesting tip about escalation. i wish i could credit my source, but i have a memory like a sieve .  (Mother Nature escalates my life by increasingly turning me into a doddering old fool.)  The tip is to escalate your game with a lightning bolt graph, rather than a smooth incline.  Regard:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/graphs.png" alt="Game Escalation Graphs"></p>
</div>
<p>In an old-school arcade game, the levels get progressively more insane, until you lose the game and have to feed the machine more quarters.  This makes sense for a coin-op that exists to devour your hard-earned pocket change, but it doesn&#8217;t make sense if you&#8217;re designing a more modern game where you <em>want</em> your player to be engaged for as long as possible.  A freemium game, for example, lives and dies by retaining players; a linear escalation curve increases the likelihood that the player will quit out of fear or exhaustion.  If he just <em>barely</em> makes it out of level 10 by the skin of his teeth, he may not even <em>want</em> to attempt level 11.  He&#8217;d sooner quit while he&#8217;s ahead.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/ballmer.jpg" alt="Steve Ballmer"></p>
<p>Is that all you got??  BRING ON THE WATER TEMPLE!!
</p></div>
<p>A modern game that strives for retention might use a lightning bolt or stair-step graph.  Here, level 10 was insanely difficult, but level 11 gives the player a bit of a breather.  One of the early examples of this approach that i can remember is the coin-op beat-em-up <b>Final Fight</b>.  After brawling your way through a preposterously crime-ridden city as the roid-raging mayor or one of his two ninja buddies, you get to smash a car.  No bad guys, no chance of death, no risk of losing &#8211; just a time-limited opportunity to smash a car.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/carSmash.jpg" alt="Final Fight Car Smash"></p>
<p>Because nothing says &#8220;tough on crime&#8221; like the mayor engaging in a little senseless vandalism.
</p></div>
<p>A more modern example is <b>Little Things</b>, a hidden object game on the iPad that i&#8217;ve been playing this week.  The levels in Little Things are, refreshingly, NOT rooms in a Victorian mansion in which a child ghost has murdered a wealthy detective.  Instead, they&#8217;re little pictures composed of even smaller pictures.  The player has to complete his quota by finding the items on the list.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/littleThings.jpg" alt="Little Things"></p>
<p>i was trying to keep this article classy, but they had to go mentioning shuttlecocks.
</p></div>
<p>Some of these pictures make it easier to find the little things within.  The umbrella&#8217;s striped design makes it easier to compartmentalize sections of the image and limit your focus.  In contrast, the hideously jam-packed cupcake is a real challenge to sift through.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/beagle.jpg" alt="Little Things Beagle"></p>
<p>Little Things beagle: easy. Little things hamburger: not-so-easy. (This is somewhat of a reversal of real life.)
</p></div>
<p>If Little Things were to escalate linearly, you&#8217;d unlock the easy pictures at the beginning of the game, and the denser pictures towards the end.  But Little Things has a staggered escalation; the densely-populated hamburger is introduced before the cinchy electric guitar.  If the escalation was linear, you&#8217;d complete 10 missions in the beagle picture before moving on to complete 10 further missions in the wheelbarrow picture.  Instead, Little Things bounces around from picture to picture, shuffling in the easier images to give the player a break.  Even the missions themselves are staggered: in one instance, you&#8217;ll find yourself scouring the level for 15 objects under distinct time pressure; the very next level, you&#8217;ll need to point at four pairs of sunglasses in one of the easier pictures.  </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_22/waldo.jpg" alt="Where's Waldo"></p>
<p>Serously &#8211; there he is.  He&#8217;s RIGHT THERE.  Just click on him.  50 points.
</p></div>
<p>The net effect is that Little Things held my attention much longer than it would have if its escalation were progressive.  Give consideration to staggered escalation if you count player retention among your next game&#8217;s goals.
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F08%2F22%2Fhow-little-things-escalate%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F08%2F22%2Fhow-little-things-escalate%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/08/22/how-little-things-escalate/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3910&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/08/22/how-little-things-escalate/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Untold Entertainment Goes Forth</title>
		<link>http://www.untoldentertainment.com/blog/2011/08/07/untold-entertainment-goes-forth/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/08/07/untold-entertainment-goes-forth/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 20:50:34 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Bidness]]></category>
		<category><![CDATA[Canadian Media News]]></category>
		<category><![CDATA[Company News]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Ideas]]></category>
		<category><![CDATA[GDC]]></category>
		<category><![CDATA[Kahoots]]></category>
		<category><![CDATA[Original Games]]></category>
		<category><![CDATA[Pimp My Portal]]></category>
		<category><![CDATA[ponycorns]]></category>
		<category><![CDATA[Spellirium]]></category>
		<category><![CDATA[TOJam]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>
		<category><![CDATA[ZombieGameWorld.com]]></category>
		<category><![CDATA[Zombies]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3895</guid>
		<description><![CDATA[When Untold Entertainment Inc. turned three last year, we were reeling from the fallout of the global economic collapse. It&#8217;s been a slow, difficult recovery, and we still have a lot of work left to do, but i&#8217;m happy to say we&#8217;ve nosed out of the tailspin. This was a landmark year for Untold; we [...]]]></description>
			<content:encoded><![CDATA[<p><center><br />
<img src="http://www.untoldentertainment.com/blog/img/2011_08_07/untoldGoesForth.png" alt="Untold Entertainment Goes Forth"><br />
</center></p>
<p>When Untold Entertainment Inc. <a href="http://www.untoldentertainment.com/blog/2010/08/09/untold-entertainment-turns-three/">turned three last year</a>, we were reeling from the fallout of the global economic collapse. It&#8217;s been a slow, difficult recovery, and we still have a lot of work left to do, but i&#8217;m happy to say we&#8217;ve nosed out of the tailspin. This was a landmark year for Untold; we are poised to have an absolutely incredible fifth year going forward.  If last year was our <em>Empire</em>, this year is our <em>Jedi</em>.  Bring on the Ewoks, baby.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/ewok.jpg" alt="Ewok"></p>
<p>Yub nub, motherf*cker.
</p></div>
<p>Here&#8217;s a look at the Year That Was.</p>
<h2>2010</h2>
<p><b>August</b></p>
<p>Last fiscal ended on a dark note.  We were struggling through <b>Spellirium</b>, our post-apocalyptic puzzle adventure game, as various production problems saw the budget sapped with very little to show for our efforts.  The year ahead had us planning to complete service projects in the hope that we&#8217;d bank enough margin to continue working on the game.</p>
<p><center><br />
<img src="http://www.untoldentertainment.com/blog/img/2011_08_07/spellirium.png" alt="Spellirium"><br />
</center></p>
<p><b>September</b></p>
<p>My book was published!  Unity 3D Game Development by Example: A Beginner&#8217;s Guide is a great introduction to game development, computer programming, and Unity 3D itself, which is a super-powerful game engine for creating on a wide variety of platforms.  Thanks to you all for buying a copy, or for recommending the book to your friends.</p>
<div class="displayed">
<p><a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881"><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/unity3dGameDevelopmentByExample.jpg" alt="Unity 3D Game Development By Example"></a></p>
</div>
<p><b>Fall</b></p>
<p>We launched <b><a href="http://www.untoldentertainment.com/blog/2010/10/31/jinx-3-escape-from-area-fitty-two/">Jinx 3: Escape from Area Fitty-Two</a></b> on YTV.com.  Jinx 3 was the first game to use UGAGS, the Untold Graphic Adventure Game System.  It supported multiple playable characters, an inventory system, a subtitle system, game variable control, and a &#8220;puppet&#8221; guidance system, which enables the developer to write commands to build in-game cutscenes.  Jinx 3 was the first UGAGS game we developed, but the second one to launch, after Heads.</p>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/2010/10/31/jinx-3-escape-from-area-fitty-two/"><img src="http://www.untoldentertainment.com/games/jinx3/featured.jpg" alt="Jinx 3: Escape from Area Fitty-Two" /></a>
</div>
<p>i spoke about UGAGS at <a href="http://www.untoldentertainment.com/blog/2010/10/23/ryan-goes-to-camp/">Gamercamp Level 2.0</a>, a Toronto convention celebrating the joy of video games.</p>
<p>October saw the publication of a now-infamous article about the <a href="http://www.untoldentertainment.com/blog/2010/10/19/canadian-vortex-game-competition-named-a-scottish-team-to-win/">Vortex Game Development Competition</a>, where the previous year&#8217;s winners were revealed to have never worked on the winning game.</p>
<p>i experimented with a feature called <a href="http://www.untoldentertainment.com/blog/linkbait-tuesdays/">Linkbait Tuesdays</a>, where i used the <a href="http://linkbaitgenerator.com/index.php">Linkbait Generator</a> to spit out randomized titles for blog posts.  It wasn&#8217;t much appreciated by my readership, and didn&#8217;t appreciably increase blog traffic, so i killed the feature.</p>
<p>On Hallowe&#8217;en, we launched our second free games portal called <a href="http://www.zombiegameworld.com">ZombieGameWorld.com</a>.  If you know the song about the old woman who swallowed the fly, you&#8217;ll understand our challenge with these portals.  We built <a href="http://www.wordgameworld.com" title="Word Game World - Play the Best Free Word Games Online">WordGameWorld.com</a> in order to attract a word game-playing audience, so that we could control the site&#8217;s ad inventory and find an audience for Spellirium.  When the site suffered from flagging traffic, i decided to build a <em>network</em> of game portals; ZombieGameWorld.com was ostensibly created to help drive traffic to WordGameWorld.com, which should drive traffic to Spellirium.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/oldLady.jpg" alt="Old lady who swallowed a fly"></p>
<p>She swallowed the spider to catch the fly.  i don&#8217;t know why she swallowed the fly. i guess she&#8217;ll die?
</p></div>
<p>To round out the fall, i <a href="http://www.untoldentertainment.com/blog/2010/11/27/movember-2010/">grew a beard</a> to win hockey tickets, despite not enjoying hockey.  i spoke at an <a href="http://www.untoldentertainment.com/blog/2010/11/03/the-mistake-i-make/">interactiveontario luncheon</a>. And i wrote an article for Mochiland.com on the disgraceful refusal by contracting companies to <a href="http://www.untoldentertainment.com/blog/2010/11/24/where-credit-is-due/">credit their Flash game developers</a>. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/movember.jpg" alt="Ryan Henson Creighton's epic moustache"></p>
<p>Why wouldn&#8217;t you want your game to be associated with this guy?
</p></div>
<p><b>Winter</b></p>
<p>As the cold weather set in, i took a position at a private college teaching Unity 3D game development.  i had hoped for a better experience than i had at Hervé Velasquez School for the Digitally Inclined, but no such luck: halfway through the course, which was dubbed Programming II (the students had supposedly been taught Flash/Actionscript for <em>four months</em> prior to my arrival), i had to dial everything back and re-teach programming basics to them.  And by basics, i mean stuff like &#8220;What does the &#8216;=&#8217; symbol do?&#8221; and  &#8220;What is a variable?&#8221; </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/name.jpg" alt="name"></p>
<p>What &#8230; is your NAME?
</p></div>
<p>The class was only eight students, but i had no fewer than two of those students&#8217; parents call or email me to ask why little Billy was getting low grades on tests. YaRly.</p>
<p>In this, i further proved the thesis in my contentious What&#8217;s Wrong with Ontario Colleges articles (<a href="http://www.untoldentertainment.com/blog/2010/02/18/whats-wrong-with-ontario-colleges-part-1/">Part 1</a> and <a href="http://www.untoldentertainment.com/blog/2010/02/23/whats-wrong-with-ontario-colleges-part-2/">Part 2</a>). Helicopter parenting and failure aversion have created a generation of non-functional kids, which i later dubbed <a href="http://www.untoldentertainment.com/blog/2011/05/18/the-most-useless-generation/">The Most Useless Generation</a>. My diagnosis is that many college undergrads have escaped high school without ever understanding <a href="http://www.untoldentertainment.com/blog/2011/08/07/how-to-be-a-student/">How to Be a Student</a> (an article i wrote while teaching last winter, which i&#8217;ve only just posted now that i&#8217;ve put some distance between myself and the situation).  </p>
<p>In the interest of helping young people be more successful, i offered <a href="http://www.untoldentertainment.com/blog/2010/11/10/my-prescription-for-more-successful-students/">My Prescription for (More) Successful Students</a>, which my students all ignored, and i wrote a serious of articles called <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Understanding Programming</a> to explain programming basics, which my students also ignored.  Oh well. As the saying goes, you can lead a horse to water, but sometimes you just have a retarded horse.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/retardedHorse.jpg" alt="retarded horse"></p>
</div>
<h2>2011</h2>
<p><b>Spring</b></p>
<p>In 2011,  we launched an exciting blog series called <a href="http://www.untoldentertainment.com/blog/pimp-my-portal/">Pimp My Portal</a>, detailing our struggles to drive traffic to ZombieGameWorld.com and WordGameWorld.com.  The hook here was <b>The World&#8217;s Most Meager Marketing Budget</b>, a pot of just $100 that i spent on Fiverr.com to buy testimonial videos to promote the site, the rationale being that search loves video.  The Old Lady who Swallowed the Fly reared her ugly head again, as i found that i had no audience to watch the videos to go to the portal to go to the OTHER portal to find out about Spellirium.  The Pimp My Portal series is ongoing.</p>
<p>Around this time, we were commissioned by The Centre for Skills Development and Training to produce a series of games to help teach workplace skills to 15-30-year-olds. The resulting game, <a href="http://www.untoldentertainment.com/blog/2011/06/22/summer-in-smallywood/">Summer in Smallywood</a>, enabled us to make a number of improvements to UGAGS, including auto-save, debug tools, navigation meshes, saved game profiles, and threaded conversations. We&#8217;re looking forward to working further with The Centre in the coming year to expand our educational gaming experience.</p>
<div class="displayed">
<p><a href="http://www.summerinsmallywood.ca"><img src="http://www.untoldentertainment.com/blog/img/2011_05_21/smallywoodTitle.jpg" alt="Summer in Smallywood by Untold Entertainment" /></a></p>
</div>
<p>In March, i admit i was feeling a little bit desperate and squirrely.  Work was trickling into the shop in fits and starts, and i was really wondering whether renewing our lease would be wise.  Wild-eyed and hungry at GDC, i was overcome with the need to let the world know <em>i am here</em>, like the tiny Whos living on a speck on a clover stalk, who ultimately issue a resounding YOPP! to show the jungle animals that they exist (and to keep from getting boiled in beezlenut oil).</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/horton.jpg" alt="Horton"></p>
<p>A game dev&#8217;s a game dev, no matter how small.
</p></div>
<p>To that end, i pulled some shenanigans at the conference, which came to be known as the famous <a href="http://www.untoldentertainment.com/blog/2011/03/05/holding-the-bag-how-i-gamed-gdcs-top-social-game-developers/" title="GDC Coin Stunt">GDC Coin Stunt</a>.  The <a href="http://www.untoldentertainment.com/blog/2011/03/15/have-you-met-my-friend-spike/">resulting press</a> on most major online games sites greased the wheels for what was to be our greatest victory yet.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/coinsShirt.jpg" alt="i have all the coins shirt"></p>
</div>
<p>Over the years, we&#8217;ve found it so difficult to drive enough steady Flash game development work that we haven&#8217;t been able to bank enough time or enough money to do our own thing.  To date, the only chance we seem to get is TOJam, an annual weekend-long Toronto game jam, during which we always produce a complete and original game.  Indeed, nearly every title in the <a href="http://www.untoldentertainment.com/games/">Original Games</a> section of our portfolio is a TOJam game, completed in one weekend by <em>me alone</em>.</p>
<p>This year, we used UGAGS to create <b><a href="http://www.ponycorns.com">Sissy&#8217;s Magical Ponycorn Adventure</a></b>.  i worked on the game with my 5-year-old daughter Cassandra.  It was no accident that i was wearing my &#8220;I have all the coins&#8221; T-Shirt in the TOJam group photo this year. After the game went live, it went viral, initially being featured on many of the same sites that covered the coin stunt. In the few months since its launch, the ponycorns game has gone on to become an international sensation (i just granted an interview to a Japanese newspaper this week!).  </p>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/games/sissy/"><img src="http://www.untoldentertainment.com/blog/img/2011_05_23/cassieAndDaddy.jpg" alt="Cassie and Daddy"></a></p>
<p>[photo by <a href="http://www.flickr.com/photos/brendanlynch/tags/tojam6">Brendan Lynch</a>]
</div>
<p>With the ponycorns game, we took a very important step to improving our viability as a dev studio by launching the game on the <a href="http://itunes.apple.com/us/app/sissys-magical-ponycorn-adventure/id445696590?mt=8">Apple iPad</a> and the <a href="http://appworld.blackberry.com/webstore/content/45781">BlackBerry Playbook</a>. On the third day of its launch week, Sissy&#8217;s Magical Ponycorn Adventure was featured by Apple in its New &#038; Noteworthy section.</p>
<p>Ponycorns also drove us to develop our first alternate revenue stream based on our original IP.  We launched the <a href="http://untoldentertainment.com/store/">Untold Booty</a> merchandise store with a number of different ponycorns-based SKUs, and have been very happy with the results.  </p>
<p>Throughout the year, i remained active with the IGDA Toronto Chapter, organizing some well-received events including the speed dating-style Game.Set.Match, the Open Mic Night rant session, Straight Outta TOJam: Pint-sized Postmortems, and the Fund in the Sun workshop. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_08_07/posters.jpg" alt="IGDA Toronto Chapter posters"></p>
</div>
<p>Through the spring, we developed a great puzzle/platformer game called <a href="http://www.untoldentertainment.com/blog/2011/07/29/spladder/">Spladder</a>, which currently runs on a number of kids&#8217; broadcaster sites &#8211; YTV.com. TVO.org and CBBC.co.uk among them.</p>
<p>We launched a new games portal called <a href="http://www.tdgameworld.com" title="Tower Defense Game World - Play the best free tower defense games">TowerDefenseGameWorld.com</a> and filled it with free tower defense games, because it&#8217;s difficult to prove a theory about a network of games portals lending each other traffic if you only have two portals.  We also gave a major upgrade to ZombieGameWorld.com by expanding it to feature zombie games and goodies on other platforms.</p>
<p>i know an old lady who swallowed a horse.  She&#8217;s dead, of course. </p>
<p><b>Summer. Future.</b></p>
<p>We&#8217;ve come full circle.  Spellirium remains unfinished, but we&#8217;re finally spending time on it again.  We poked Kahoots with a stick to see if it was still twitching. Thankfully, it is! We&#8217;ve made some creative changes to it to spare a fellow indie game dev company some unpleasant legal strife; look forward to a Kahoots-related announcement in the coming months.  </p>
<p>i&#8217;m writing the 3.x update to my Unity 3D book, which will be ready shortly (send me an email and i&#8217;ll add you to our notification list when the update is released).</p>
<p>Going forward, our plan is to leverage the success of the ponycorns game to make major in-roads into game development and education for kids (see our article on CBC.ca).  i&#8217;m preparing a pilot project with Cassie&#8217;s elementary school this fall.  We&#8217;re preparing the unstoppable UGAGS engine for a business-to-business, and then consumer, release &#8211; expect it to have a kid-friendly interface.    We&#8217;re polling people for their interest in an iPhone/iPod version of the game (send us an email!).  i&#8217;ll be delivering my conference session <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=118&#038;presentation_id=1656" title="Ponycorns: Lightning in a Jar">Ponycorns: Lightning in a Jar</a> at the Screens festival this fall, and at other conventions throughout the year.  Ponycorns is being translated into Japanese in anticipation of the Sense of Wonder Night at the Tokyo Games Show.  </p>
<p>Untold Entertainment&#8217;s fifth year will be filled with low-life panda bears, daily word puzzles, gamesByKids, and more great articles about game development and education, peppered with rude jokes and stolen LOLcat pictures.  Thanks so much for your support, everyone!  i&#8217;m really looking forward to writing an amazing recap next year.</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F08%2F07%2Funtold-entertainment-goes-forth%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F08%2F07%2Funtold-entertainment-goes-forth%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/08/07/untold-entertainment-goes-forth/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3895&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/08/07/untold-entertainment-goes-forth/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cooking With Flash: Drawing Complex Images using Tweened Animation</title>
		<link>http://www.untoldentertainment.com/blog/2011/05/09/cooking-with-flash-drawing-complex-images-using-tweened-animation/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/05/09/cooking-with-flash-drawing-complex-images-using-tweened-animation/#comments</comments>
		<pubDate>Mon, 09 May 2011 14:41:38 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cooking With Flash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3651</guid>
		<description><![CDATA[Drawing repeating elements in Flash can be a real asspain. This tutorial will teach you a valuable trick with the timeline to help you draw things like starbursts, buzzsaws, clock faces, and repeating elements along a path. Check out this vector graphic of a sun. Sure, you can individually copy and rotate all those flames [...]]]></description>
			<content:encoded><![CDATA[<p>Drawing repeating elements in Flash can be a real asspain.  This tutorial will teach you a valuable trick with the timeline to help you draw things like starbursts, buzzsaws, clock faces, and repeating elements along a path.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/sun.jpg" alt="sun">
</div>
<p>Check out this vector graphic of a sun.  Sure, you can individually copy and rotate all those flames and then meticulously hand-position them,  but life&#8217;s too short and you’ve got too much other awesome stuff to do. There&#8217;s a faster, easier way!</p>
<h2>Step 1: Draw your graphics</h2>
<p>To begin, I&#8217;ve just drawn a circle and a little flame graphic. I filled them both with a gradient so they look less junky.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/flameAndCircle.jpg" alt="sun">
</div>
<h2>Step 2: Symbolize your graphics</h2>
<p>Select the circle and press F8, or click Modify > Convert to Symbol.  Enter a name for your symbol – anything you like – and make sure the Registration point is in the center.  Press OK when you’re finished.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/convertToSymbol.jpg" alt="sun">
</div>
<h2>Step 3: Create an Empty Movie Clip</h2>
<p>Press CTRL+F8 or click Insert > New Symbol &#8230; to create an empty Movie Clip.  Again, call it whatever you like and click OK.  Then click the Scene 1 tab to jump back out to the main timeline.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/emptySymbol.jpg" alt="sun">
</div>
<p>Press CTRL + L or click Window > Library to bring up the Library.  Click and drag the empty Movie Clip you just created and drag it to the Stage.  The empty Movie Clip looks like a white dot. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/whiteDot.jpg" alt="sun">
</div>
<h2>Step 4: Align the two Movie Clips</h2>
<p>Press CTRL + K or click Window > Align in the menus to bring up the Align panel.  Click and drag to range-select both Movie Clips at once.  Click the “Align horizontal center” and “Align vertical center” buttons (highlighted in red in the image) to align the center points of the two clips.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/align.jpg" alt="sun">
</div>
<h2>Step 5: Cut and paste the repeated element into the empty Movie Clip.</h2>
<p>Select the artwork for the repeated element and press CTRL+X or Edit > Cut in the menus to delete it and copy it to memory in the clipboard.</p>
<p>Now, double-click the empty Movie Clip (the white dot) to edit it. If you accidentally double-click the circle, click the Scene 1 button to jump back out to the main timeline and try again.  Alternately, you can double-click the empty clip from the library to edit it. </p>
<p>Finally, press CTRL+V or Edit > Paste to paste the repeated element artwork from the clipboard into the empty Movie Clip.  Position the artwork where you’d like it to appear; in the case of our sun graphic, we’ll move the little flame to the edge of the circle.  Click the Scene 1 button to jump back out to the main timeline when you’re ready.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/pasteRepeated.jpg" alt="sun">
</div>
<h2>Step 6: Prep the timeline.</h2>
<p>Select the repeated element (in this case, the flame Movie Clip) and press CTRL+X or Edit > Cut to delete it and copy it to the clipboard.  </p>
<p>Click the New Layer button at the bottom left of the Timeline window.  Click on the first frame of the newly-added layer, and press CTRL+SHIFT+V to paste the repeated element in exactly the same place. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/pasteInPlace.jpg" alt="sun">
</div>
<h2>Step 7: Spin the clip.</h2>
<p>Click on frame 30 of the main timeline in the newly-added layer.  Press F6 or click Insert > Timeline > Keyframe to drop a new Keyframe there.  You’ll see a black dot on frame 30.</p>
<p>Click on Frame 1 of the new layer.  Right-click and select Create Classic Tween.  An arrow with a blue background appears to indicate that Flash will interpolate the position, rotation, scale and color effects of this Movie Clip across the frame range. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/classicTween.jpg" alt="sun">
</div>
<p>Open the Properties panel (Windows > Properties or CTRL+F3).  Select the repeated element Movie Clip.  The context-sensitive Properties panel updates to show Movie Clip properties.</p>
<p>Under the Tweening heading, choose CW (clockwise) from the Rotate: dropdown.  (You may need to click the little triangle to expand the Tweening section).  This makes the repeated element rotate around its registration point for the duration of the animation span.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/clockwise.jpg" alt="sun">
</div>
</h2>
<p>Step 8: Adjust the animation with Onion-Skinning.</h2>
<p>Click the Onion Skin button at the bottom of the Timeline window to turn on Onion Skinning.  Click and drag the grey animation range gizmo at the top of the Timeline window to stretch across the entire animation range. </p>
<p>Now you can clearly see how your repeated element is distributed around its registration point.  If the distribution is too sparse, click the pink rectangular Playhead at the top of the Timeline window and hold down the F5 key (or repeatedly click Insert > Timeline > Frame if you’re a sucker) until the distribution is to your likely.  If the distribution is too dense, press SHIFT+F5 to delete frames until it looks good.  If you’re deleting frames, make sure you either lock the lower layer, or move away from Frame 1, or else you’ll delete the lower layer artwork!</p>
<p>The following images show how differing frame range lengths can affect the distribution of your repeated elements:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/skin1.jpg" alt="sun">
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/skin2.jpg" alt="sun">
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/skin3.jpg" alt="sun">
</div>
<h2>Step 9: Turn the interpolated frames into symbol instances.</h2>
<p>Right now, those repeated elements may look exactly the way you want them, but they’re not “real”.  What you’re seeing is just the motion trail of a single Movie Clip instance as it revolves through its animation.<br />
To turn these phantoms into actual symbol instances, click and drag to select the entire range of animated frames, and press F6 to convert them all to keyframes.  Now, each frame contains an actual “physical” instance of the Movie Clip.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/physical.jpg" alt="sun">
</div>
<h2>Step 10: Gather the elements together on one frame.</h2>
<p>Click the Edit Multiple Frames button at the bottom of the Timeline window.  </p>
<p>Click the dot beneath the Lock column on the lower layer, to keep from messing with the graphics on the lower frame.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/lock.jpg" alt="sun">
</div>
<p>Press CTRL+A to select all of the (unlocked) repeated elements. The Edit Multiple Frames mode enables you to select all of the instances across the frame range.</p>
<p>Press CTRL+X or Edit > Cut to delete all of the repeated elements and copy them to the clipboard.<br />
Uncheck the Edit Multiple Frames button.  Click on the first frame, and press CTRL+SHIFT+V to paste the repeated elements in place.  </p>
<h2>Step 11: Tidy up.</h2>
<p>Click and drag to select the animation range from frame 2 to the last frame.  Press CTRL+F6 to delete all of the empty, blue animated keyframes. Press SHIFT+F5 to delete the frames so that your timeline is back to a single frame.</p>
<p>Click and drag the top layer below the bottom layer to swap their z-depth order.  This put the repeated elements behind the circle.  Looks pretty good!  </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/sun.jpg" alt="sun">
</div>
<p>This trick works for more than just straight lathe effects.  You can animate a MovieClip along a path and add scale effects to it before F6-ing the whole affair.  Check out the tail scales on this super-realistic dinosaur:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/dinosaur.jpg" alt="sun">
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F05%2F09%2Fcooking-with-flash-drawing-complex-images-using-tweened-animation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F05%2F09%2Fcooking-with-flash-drawing-complex-images-using-tweened-animation%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/05/09/cooking-with-flash-drawing-complex-images-using-tweened-animation/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3651&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/05/09/cooking-with-flash-drawing-complex-images-using-tweened-animation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Cooking With Flash: Animating a Bouncing Ball</title>
		<link>http://www.untoldentertainment.com/blog/2011/05/03/cooking-with-flash-animating-a-bouncing-ball/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/05/03/cooking-with-flash-animating-a-bouncing-ball/#comments</comments>
		<pubDate>Tue, 03 May 2011 15:53:39 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3634</guid>
		<description><![CDATA[Animating a bouncing ball is one of the first things you learn in a classical animation program. These days, many programs teach video game development, including art asset prep, concept art, 3d modelling, etc etc, but they gloss over (or don&#8217;t even bother teaching) some very basic concepts than any creator should know. Here&#8217;s how [...]]]></description>
			<content:encoded><![CDATA[<p>Animating a bouncing ball is one of the first things you learn in a classical animation program.  These days, many programs teach video game development, including art asset prep, concept art, 3d modelling, etc etc, but they gloss over (or don&#8217;t even bother teaching) some very basic concepts than any creator should know.</p>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-good.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-good.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>Here&#8217;s how to animate a bouncing ball convincingly using Flash CS5 (though these steps will work in most &#8211; if not all -iterations of the Flash software).</p>
<h2>Step 1: Create the Ball</h2>
<ol>
<li>In the tool palette, click and hold the mouse button on the &#8220;stroke&#8221; swatch.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/strokeSwatch.jpg" alt="stroke swatch">
</div>
<li>Select the strike-through swatch. Our ball art won&#8217;t have a stroke.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/strikeThrough.jpg" alt="strikethrough">
</div>
<li>Optionally, click and hold the mouse button on the &#8220;fill&#8221; swatch and choose a colour for your ball.  i went with classic cherry red (#0xCC0000).
<li>Again in the tool palette, Select the Oval tool. If you can&#8217;t see it, press and hold on the Rectangle tool &#8211; the Oval tool is hiding in a fly-out. You could also press the &#8220;O&#8221; key on your keyboard.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/ovalTool.jpg" alt="Flash oval tool">
</div>
<li>Click and drag the mouse to draw a circle on the screen. Hold the SHIFT key to constrain the circle&#8217;s proportions so that you don&#8217;t end up with an oblong ellipse.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/drawOval.jpg" alt="draw oval in Flash">
</div>
<li>Click the selection (black arrow) tool. You use this one a lot, so why not learn the keyboard shortcut?  It&#8217;s &#8220;V&#8221;.  (Pointy, like an arrow.  Get it?)
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/blackArrow.jpg" alt="Flash selection tool">
</div>
<li>Either double-click the raw circle artwork, or range select it (drag a selection box around the artwork).  It goes &#8220;fuzzy&#8221;.  (And it wouldn&#8217;t be an Untold Entertainment tutorial without some mention of fuzzy balls.)
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/fuzzyBall.jpg" alt="fuzzy ball">
</div>
<li>With the artwork selected, choose Modify>Convert to Symbol in the menu, or press the F8 key.
<li>In the resulting pop-up, type &#8220;Ball&#8221; as the MovieClip&#8217;s name.
<li>Choose the bottom-middle for the registration point.  <em>This is key to animating a bouncing ball properly!</em>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/convertToSymbol.jpg" alt="Convert to symbol">
</div>
</ol>
<p>On or around the Flash MX release, the Flash engineers added a feature where a MovieClip can have its registration point in a certain place (ours is at the bottom of the ball), but there&#8217;s a second point &#8211; an <em>anchor point</em> &#8211; that can move around according to the needs of our animation.  i don&#8217;t know why the anchor point doesn&#8217;t move to the bottom of the ball when we clearly want it there.  Anyway, the last bit in this section is to move the ball&#8217;s anchor point down to the bottom middle, where its registration point is. </p>
<ol>
<li>Make sure that snapping is turned ON.  The Anchor icon in the Tool palette should be depressed (cheer up, little icon &#8211; things can only get better).  You can quickly toggle snapping with the shortcut CTRL + SHIFT + /.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/snap.jpg" alt="Flash Snap Tool">
</div>
<li>Click on the Free Transform Tool.  In addition to rotating, skewing and scaling things, this tool lets us move our anchor point around.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/freeTransform.jpg" alt="Flash Free Transform Tool">
</div>
<li>The anchor point is the white dot in the center of the ball MovieClip.  Click and drag it to the bottom-middle of the ball. Since snapping&#8217;s turned on, it should snap into place.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/snapAnchor.jpg" alt="Snap Anchor">
</div>
</ol>
<p>With the anchor point snapped to the bottom of the ball, we can properly squash and stretch it.  &#8220;Squash n&#8217; stretch&#8221; is one of the principles of animation laid out by Disney&#8217;s Twelve Old Men in the indispensible book <a href="http://www.amazon.com/gp/product/0786860707/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=untoldentert-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399353&#038;creativeASIN=0786860707">The ILLUSION OF LIFE: DISNEY ANIMATION</a><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=0786860707&#038;camp=217145&#038;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=0786860707&#038;camp=217145&#038;creative=399357" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. </p>
<div class="displayed">
<p><a href="http://www.amazon.com/gp/product/0786860707/ref=as_li_qf_sp_asin_tl?ie=UTF8&#038;tag=untoldentert-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399353&#038;creativeASIN=0786860707"><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/illusionOfLife.jpg" alt="The Illusion of Life"></a><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=0786860707&#038;camp=217145&#038;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><img src="http://www.assoc-amazon.com/e/ir?t=untoldentert-20&#038;l=as2&#038;o=1&#038;a=0786860707&#038;camp=217145&#038;creative=399357" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></a>
</div>
<p>If you&#8217;re interested in animation, i highly recommend studying that book and the Disney principles: arc of motion, squash n&#8217; stretch, anticipation, secondary motion, follow-through &#8230; fantastic stuff!</p>
<h2>Step 2: Rough-In the Animation</h2>
<p>Thanks to the magic of computerized interpolative animation (AKA &#8220;tweening&#8221;), it&#8217;s a pretty quick job to get the ball bouncing.  Getting it bouncing <em>convincingly</em> takes a tiny bit more effort.</p>
<p>So let&#8217;s rough it in first:</p>
<ol>
<li>Click on frame 5 in the Timeline.
<li>Click Insert>Timeline>Keyframe in the menu.  If you&#8217;re going to do even a smidge of animation in Flash, you should really learn the Timeline shortcuts:
<p>    &#8211; F5: insert a blank frame<br />
    &#8211; F6: insert a keyframe<br />
    &#8211; F7: insert a blank keyframe<br />
    &#8211; SHIFT + F5: delete a blank frame<br />
    &#8211; SHIFT + F6: delete a keyframe<br />
    &#8211; SHIFT + F7: delete a blank keyframe</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/frame5.jpg" alt="Flash insert keyframe">
</div>
<p>Inserting a keyframe copies everything from the previous keyframe (the first one Flash finds travelling backwards along the timeline).  In the case of our Ball MovieClip, Flash copies the ball&#8217;s position, rotation, scale, and colour effects. This is a Good Thing.™</p>
<li>Click on frame 10 of the Timeline, and press F6 to add another keyframe.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/frame10.jpg" alt="Flash insert keyframe">
</div>
<p>Now we have three instances of the Ball, on frames 1, 5, and 10.  Frames 1 and 10 will depict the Ball in its &#8220;up&#8221; state, and frame 5 will be the &#8220;down&#8221; state.</p>
<li>Click on frame 5.
<li>Click on the Ball MovieClip, and move it down the screen.  i moved mine about 90 pixels down, and my Ball is 50 pixels in diameter.  Don&#8217;t worry about botching this step &#8211; you can easily adjust your animation later.
<li>Click on any frame in the Timeline from 1-4.
<li>Right-click and choose &#8220;Create Classic Tween&#8221; from the context menu, or choose the same option from the program menu &#8211; Insert>Classic Tween.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/createClassicTween.jpg" alt="Flash Create Classic Tween">
</div>
<p>Flash offers two different styles of interpolative animation: the new Motion Tween, for designers who want full spline control over every axis of an animation, and Classic Tween, for us old-schoolers who can&#8217;t be arsed.  (Guess which kind of developer i am?)</p>
<li>Similarly, add a Classic tween between frames 5 and 10.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/tweens.jpg" alt="Flash Classic Tweens">
</div>
<p>The first tween we created tells Flash to figure out the in-between drawings (&#8220;tweens&#8221;) from the Ball&#8217;s &#8220;up&#8221; keyframe and its &#8220;down&#8221; keyframe.  Likewise, the second tween tells Flash to calculate the in-between drawings from the ball&#8217;s &#8220;down&#8221; keyframe to its &#8220;up&#8221; keyframe.</p>
<p>Play your animation by pressing the ENTER key on your keyboard, or better yet, click Control>Test Movie>Test in the menus, or hit CTRL+ENTER.  Your Ball should animate up and down, <em>crappily</em>.  </p>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-crappy.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-crappy.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>Our Ball is <em>moving</em>, but it&#8217;s not <em>animating</em>.  The <em>Illusion of Life</em> isn&#8217;t there.  We&#8217;re going to change that.</p>
<h2>Step 3: Breath Some Life Into It</h2>
<p>The type of ball we&#8217;ve got bouncing right now is very very stiff.  It&#8217;s a cue ball or a bowling ball or a brass ball.  It isn&#8217;t a very fun ball.  It&#8217;s not soft or squishy.  It has no personality.  By adding a tiny bit of squash n&#8217; stretch, we can eke a lot more <em>verve</em> out of it.</p>
<p>The squash n&#8217; stretch principal is this: squishy, bouncy, rubbery things are more fun to watch on screen than rigid things.  You&#8217;re &#8220;allowed&#8221; to squash or stretch something as much as you like, even to extremes, as long as the body&#8217;s volume stays the same.  So if you stretch something up very tall, it has to simultaneously get very thin, or else it appears to <em>gain mass</em>, and it just won&#8217;t look right.</p>
<p>By the same token, if you flatten something by making it short, all that <em>stuff</em> has to seep out somewhere, so the shape has to simultaneously become very wide.</p>
<p>It makes sense to add a squash to the ball on the frame when it hits the ground, and maybe a slight stretch when it&#8217;s up in the air.  Let&#8217;s do it:</p>
<ol>
<li>Click on frame 5.
<li>Click on the Free Transform tool.
<li>Select the Ball MovieClip.
<li>Drag the handles around to make your ball short and squat.  Try to conserve the ball&#8217;s mass.  For every inch that you flatten it, you&#8217;ve gotta squash it by the same amount.
</ol>
<p>Now test your movie.</p>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ballEarlySquish.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ballEarlySquish.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>Uh-oh &#8230; this isn&#8217;t good. Something doesn&#8217;t quite look right.  Sure, the ball squishes when it lands, but &#8230; what&#8217;s going on?</p>
<p>The reason it doesn&#8217;t play well is that Flash is interpolating the squish from frame 1, when the ball is up in the air, all the way down to frame 5, when it hits the ground.  Of course, the ball&#8217;s only going to squish when it actually makes contact with a hard surface.  </p>
<p>Pres CTRL+Z or choose the Undo options from the Edit menu to undo the last few steps, until the ball on frame 5 is unsquished, and there are no Classic Tweens in the timeline.  (If you undo too many steps, you can choose CTRL + Y or Edit>Redo to <em>undo your undo</em></p>
<h2>Step 4: Protect the Squish</h2>
<p>In order to prevent Flash from interpolating the squish all the way through the animation, we need to &#8220;protect&#8221; the squish frame.  We can do this by placing two keyframes, one on either side of frame 5.  By doing this, we ask Flash to tween only the ball&#8217;s position on the way down, and only its position on the way up.  Then, on the &#8220;protected&#8221; 5th frame, we squish the ball.</p>
<ol>
<li>Place a keyframe on frame 6.  This copies the ball in its &#8220;down&#8221; state from frame 5.
<li>Press CTRL+C on the keyboard, or Edit>Copy to copy the ball in this position.
<li>Place a new blank keyframe on frame 4.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/blankKeyframe.jpg" alt="Flash blank keyframe">
</div>
<li>Press CTRL+SHIFT+V or choose Edit>Paste in Place to paste the ball in its &#8220;down&#8221; position, exactly as it is on frames 5 and 6.
<li>Re-add the Classic Tweens leading from frames 1 and 6.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/protected.jpg" alt="Protected squish">
</div>
<li>Now that the squish frame is protected, you can go back and add the squish to the ball on frame 5.
</ol>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ballGoodSquish.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ballGoodSquish.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>It&#8217;s better with the squish, but it&#8217;s not perfect.  Let&#8217;s try adding a stretch to the &#8220;up&#8221; positions.</p>
<ol>
<li>On frame 1, stretch the ball out a touch using the Free Transform tool.
<li>Since the animation loops, the first and the last frames have to match. Copy the ball from this frame.
<li>Click on the last frame, frame 10.
<li>Delete the ball from frame 10.  This breaks our Classic Tween, and we get a dotted line leading to a blank keyframe.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/brokenTween.jpg" alt="Broken tween">
</div>
<li>Press CTRL+SHIFT+V or select Edit>Past in Place to paste the stretched ball.  The Classic Tween is back to normal, now that it has something to animate towards.
</ol>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ballWithStretch.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ballWithStretch.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>Okay!  Almost there!  It&#8217;s looking better with that stretch.  You may wonder why i&#8217;m not asking you to &#8220;protect&#8221; the stretch frames like we did with the squashed frame.  That&#8217;s because while the ball shouldn&#8217;t squish until it hits the floor, it actually <em>should</em> lengthen as it travels up through the air.</p>
<p>The worst thing about our animation right now is the timing.  The ball moves pretty robotically, and it has a real &#8220;computer animated&#8221; feel to it.  In order to soften this up, we&#8217;ll apply some timing to the animation.</p>
<h2>Step 5: Apply Timing</h2>
<p>To make the ball a little more phyiscally believable, we need to slow it down on the way up.  If you&#8217;ve ever seen super-slow-motion footage of someone hitting a baseball, or if you&#8217;ve studied Newtonian physics, you&#8217;ll know that the baseball actually comes to a dead stop as its energy is transferred to the bat.  The bat, in turn, applies force in the opposite direction to the ball.</p>
<p>Similarly, there&#8217;s a point at which our ball hangs in the air and stops moving, before heading back down towards the ground.  It decelerates (moves increasingly more slowly) as it reaches the apex of its bounce, and accelerates as it reverses direction and heads towards the ground.</p>
<p>We need to apply some <em>easing</em> to the ball to imitate this real-world behaviour.</p>
<p>Easing can front- or back-load a tween animation so that it&#8217;s slower or faster at the beginning or the end.</p>
<p>Here&#8217;s a picture of a tweened box animation with no easing:</p>
<p>
<object width="550" height="400">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/boxNoEasing.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="550" height="400" src="http://www.untoldentertainment.com/blog/img/2011_04_20/boxNoEasing.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>The box&#8217;s in-between frames are evenly distributed between the start and end points.</p>
<p>And here it is with &#8220;Ease In&#8221;:</p>
<p>
<object width="550" height="400">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/boxEaseIn.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="550" height="400" src="http://www.untoldentertainment.com/blog/img/2011_04_20/boxEaseIn.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>The box appears to move more slowly at the beginning of its animation, and it speeds up as it reaches the end point.  We can see this is because the box&#8217;s in-betweens are bunched together at the beginning.</p>
<p>Finally, here&#8217;s what &#8220;Ease Out&#8221; looks like:</p>
<p>
<object width="550" height="400">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/boxEaseOut.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="550" height="400" src="http://www.untoldentertainment.com/blog/img/2011_04_20/boxEaseOut.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>The box appears to slow down at the end of the animation, because its in-between frames are bunched together there.</p>
<p>So we return to our bouncing ball.  We want the tween coming out of frame 1 to Ease In, so that it accelerates towards the ground.  We want the tween coming into frame 10 to Ease Out, so that the ball slows down when it reaches the top of its bounce.</p>
<ol>
<li>Click on frame 1.
<li>In the properties panel, drag the number 0 next to the &#8220;Ease:&#8221; label all the way to the left, until it reaches -100 and the word &#8220;in&#8221; appears.  You can also single-click on the number and it becomes an input field.  Type &#8220;-100&#8243; into the field and press ENTER.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/easeIn.jpg" alt="Flash Ease In">
</div>
<li>Click on frame 6.
<li>In the properties panel, slide the Ease: to the right until it reaches 100/out, or single-click the field and type &#8220;100&#8243;, then press ENTER.
<li>For the finishing touches, i decided to slow the squish down a bit.  First i added a frame on either side of the squish:
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/finishingTouches1.jpg" alt="Animated ball in Flash finishing touches">
</div>
<li>&#8230; and then i added Classic Tweens coming into and going out of the squish.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_20/finishingTouches2.jpg" alt="Animated ball in Flash finishing touches">
</div>
</ol>
<p>Test your movie.</p>
<p>
<object width="300" height="200">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-good.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="300" height="200" src="http://www.untoldentertainment.com/blog/img/2011_04_20/ball-good.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>The combination of easing and squash n&#8217; stretch give the ball a lot of spunk and life!  Instead of a ball that looks like it was animated by a robot, we&#8217;ve got a spunky, squishy object that&#8217;s a lot more fun to watch.</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F05%2F03%2Fcooking-with-flash-animating-a-bouncing-ball%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F05%2F03%2Fcooking-with-flash-animating-a-bouncing-ball%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/05/03/cooking-with-flash-animating-a-bouncing-ball/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3634&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/05/03/cooking-with-flash-animating-a-bouncing-ball/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Just in Time for Easter: Zombunny Cookies</title>
		<link>http://www.untoldentertainment.com/blog/2011/04/21/just-in-time-for-easter-zombunny-cookies/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/04/21/just-in-time-for-easter-zombunny-cookies/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 03:57:28 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Christianity]]></category>
		<category><![CDATA[Morality]]></category>
		<category><![CDATA[Pimp My Game]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ZombieGameWorld.com]]></category>
		<category><![CDATA[Zombies]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3653</guid>
		<description><![CDATA[Jesus knows a thing or two about rising from the dead, so it&#8217;s not a huge stretch to envision re-animated rabbits crawling out of their pastoral resting places during the Easter holiday. A simple sugar cookie recipe, some cookie cutters, and creative icing skillz are all you need to bring these ferocious zombunnies to life [...]]]></description>
			<content:encoded><![CDATA[<p>Jesus knows a thing or two about rising from the dead, so it&#8217;s not a huge stretch to envision re-animated rabbits crawling out of their pastoral resting places during the Easter holiday.  A simple sugar cookie recipe, some cookie cutters, and creative icing skillz are all you need to bring these ferocious zombunnies to life in your own kitchen:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/zombunny1.jpg" alt="Zombunny Easter Cookies from ZombieGameWorld.com"></p>
<p>Mmm &#8230; sacrilicious.
</p></div>
<h2>No-Fail Sugar Cookies</h2>
<ul>
<li>6 cups flour
<li>3 tsp. baking powder
<li>2 cups butter
<li>2 cups sugar
<li>2 eggs
<li>2 tsp. vanilla or almond extract
<li>1 tsp. salt
<li>fresh brains, to taste
</ul>
<p>Cream butter and sugar until light and fluffy.  Add eggs and vanilla, and mix well. Mix dry ingredients and add gradually to butter mixture.  Mix until flour is completely integrated and the dough comes together.</p>
<p>Chill for 1 to 2 hours, or press dough between parchment paper and place in the fridge.  By the time you&#8217;re finished doing this, the initial batch of rolled dough will be chilled enough to work with.  Fry brains and strain them of excess juices.  Dry brains on a plate, and crumble over cookies immediately after removing them from the oven.  Leftover brain juices may be used in unwholesome ritual ceremonies.</p>
<p>Roll dough to desired thickness and cut into bunny shapes.  Bake on an ungreased baking sheet at 350 degrees for 8-10 minutes.  Yields one small army of zombunnies.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/zombunny2.jpg" alt="Zombunny Easter Cookies from ZombieGameWorld.com">
</div>
<h2>Poured Fondant Cookie Icing</h2>
<ul>
<li>1 &#8211; 1 1/2 cups icing sugar, as needed
<li>1 tbsp corn syrup
<li>1 1/2 tbsp water
</ul>
<p>Mix ingredients as needed until the icing is runny enough to pour, but thick enough to set.  Apply to cooled cookies with an icing bag or jam knife. Plastic baggies with holes snipped out of their corners make inexpensive icing bags, and allow for easy clean-up*.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_04_21/zombunny3.jpg" alt="Zombunny Easter Cookies from ZombieGameWorld.com"></p>
<p>*Rampaging zombunnies may make clean-up more difficult.
</p></div>
<p>Visit <a href="http://www.zombiegameworld.com">ZombieGameWorld.com</a> for more fun stuff!
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F04%2F21%2Fjust-in-time-for-easter-zombunny-cookies%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F04%2F21%2Fjust-in-time-for-easter-zombunny-cookies%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/04/21/just-in-time-for-easter-zombunny-cookies/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3653&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/04/21/just-in-time-for-easter-zombunny-cookies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>i wrote a book.</title>
		<link>http://www.untoldentertainment.com/blog/2011/03/29/i-wrote-a-book/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/03/29/i-wrote-a-book/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 01:44:31 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3557</guid>
		<description><![CDATA[This blog&#8217;s been enjoying a steady influx of new readers since my recent GDC shenanigans. Thank you, and welcome! If you haven&#8217;t peered over to my sidebar, here&#8217;s the story so far: i wrote a book. i wrote a book on a subject i knew almost nothing about, and i did it never having written [...]]]></description>
			<content:encoded><![CDATA[<p>This blog&#8217;s been enjoying a steady influx of new readers since my recent GDC shenanigans.  Thank you, and welcome! If you haven&#8217;t peered over to my sidebar, here&#8217;s the story so far: i wrote a book.  i wrote a book on a subject i knew almost nothing about, and i did it never having written a book before.  This is the story of how that happened.</p>
<h2>i Killed a Guy</h2>
<p>End of story.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/chalk.jpg" alt="Chalk outline"></p>
<p>i swear that&#8217;s how it happened, officer.
</p></div>
<h2>New Header</h2>
<p>Alright, no &#8211; but that would have been interesting.</p>
<p>i&#8217;d been aware of Unity 3D, a game engine, right from its early days. i was working at a kids&#8217; media conglomerate and we were researching development tools for a new kids MMO.  Unity was used to develop Cartoon Network&#8217;s FusionFall MMO.  The drawback was that the software only ran on a Mac.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/mac.png" alt="Running on a Mac"></p>
</div>
<p>A year later i was at GDC, and Unity had announced a PC version. i saw them on the show floor, and tried comparing them with Torque 3D. At that time, reps for the two companies were doing a lot of mud-slinging, and a lot of FUD was bouncing around between the booths.  So when i returned home, i asked a simple question on a LinkedIn forum:  Unity or Torque?  The answer was overwhelmingly in favour of Unity, to the tune of hundreds of responses.  i knew i was on to something.</p>
<h2>Get Me Summa Dat</h2>
<p>i <em>wanted</em> to use Unity, but there were still a few barriers in the way.  One of them was removed in short order when Unity moved to a free model.  But there was still the problem that both 3D Studio Max and Maya, 3D software crucial to developing assets for Unity games, were $4000 a seat (after Autodesk had killed the $2k entry level version of each product).  $Four large is a lot to swing on software for a small studio like mine. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/asshole.jpg" alt="Asshole"></p>
<p>Why don&#8217;t i just pirate the software?  Because unlike the guy at Autodesk who decided to cut the entry-level versions of both pieces of software and price them identically, i&#8217;m not an asshole.
</p></div>
<p>Still, i could tell Unity was special, and i wanted to be involved.  So i started tweeting about it.  i kept a watch through Tweetdeck on the #Unity3D hash tag, and if any interesting info floated by, i retweeted it.  i set up a new blogbook here called <a href="http://www.untoldentertainment.com/blog/unity-nuub/">Unity Nuub</a>, which would hold interesting articles and links related to the software.  i downloaded Unity and goofed off with the software a little bit.  i played Unity games.  My interest was piqued, but my activity level was low.</p>
<h2>Where There&#8217;s a Will&#8230;</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/will.jpg" alt="Unity 3D Game Development Essentials"></p>
</div>
<p>Around that time, a small publisher out of the UK called Packt was putting out the very first book on Unity 3D, by Will Goldstone.  The publisher contacted me and asked if i wanted a free review copy in exchange for a review on my site.  i said &#8220;sure&#8221;.  How did they find me?  Presumably through Twitter, i&#8217;d made a connection between myself and Unity, and i must have come up in a few Google searches.</p>
<p>A short time afterward, David Barnes (<a href="http://www.untoldentertainment.com/fbindie">@fbindie</a>) from Packt wrote me up saying they wanted to do a few more Unity books.  What types of books did i think they should publish?  i gave him my feedback.  His next question, which left me a bit breathless, was: &#8220;Do you have any interest in writing any of them?&#8221;</p>
<h2>Dusting off the Bucket List</h2>
<p>i don&#8217;t know about you, but i&#8217;ve always wanted to be a published author.  That was always just &#8230; something i had on my list, along with &#8220;fly a helicopter&#8221; and &#8220;marry rich&#8221;.  Sadly, few of our childhood fantasies end up coming true &#8230; my wife is flat-ass broke, and we all know helicopters don&#8217;t exist.  Once i was ten years into the games industry, i had resigned myself to the fact that i would probably never be a published author, so i put it out of my mind.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/pianist.jpg" alt="12 Inch Pianst"></p>
<p>Abandoned, too, was my hope of having a twelve-inch pianist.
</p></div>
<p>But here it was: an offer to write a book.  A book on something i knew nothing about.</p>
<p>i was upfront with David. &#8220;i really have no idea how to use Unity.&#8221;  He looked up my <em>bona fides</em>: trained in 3D Studio Max in college, worked 10 years as a game developer working with Flash, had a rockin&#8217; blog packed with dick jokes and Actionscript tutorials (but mostly dick jokes.)  He said a cookbook might be beyond me, but i could probably write a decent beginner book.</p>
<p>i told him i&#8217;d need some time to get up to speed on the software.  i&#8217;d never made a game in Unity. i&#8217;d never done <em>anything</em> in Unity, for that matter.  (But neither had many other people, really &#8211; the software was only 3 years old, and only 1 year out of the gate on the PC.  Unity was news to a lot of people.)</p>
<p>David asked me point blank: &#8220;How long will it take you to learn Unity well enough to write a book about it?&#8221;</p>
<p>Gripping my desk chair and chewing my lips as i answered his email, i typed &#8220;Well, i suppose by the time i finish writing a book on it, i&#8217;ll know the software pretty well.&#8221;</p>
<p>And off we went.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/waterski.jpg" alt="Waterski"></p>
<p>YeeeeHAAAAWWW!
</p></div>
<h2>The Luckiest Boy in the World</h2>
<p>Are you hating me right now?  Maybe you&#8217;ve read my other article, <a href="http://www.untoldentertainment.com/blog/2010/04/20/tenure/">TENure</a>, about how i was hired as a game developer despite not ever having made a game before?  Maybe you want to wrap my face around your foot? </p>
<p>Who do you think should have written the second-ever published book on Unity?  A Unity expert, i suppose!  Well, can that Unity expert write?  Does that Unity expert have the considerable time and energy for a book?  And better yet, will that Unity expert remember what it was like to NOT be an expert? i don&#8217;t know about you, but i&#8217;ve spent a lot of money over the years on books by subject matter experts who move way, way too quickly.  My mandate was to write a beginner book that beginners could <em>truly</em> get through.  And not just Unity beginners: <em>game development</em> beginners.  For example, there&#8217;s a heading in the book that says &#8220;What is code?&#8221;, and another section that briefs the reader on how 3D models are put together.</p>
<h2>The Backlash</h2>
<p>i caught a lot of flack from my colleagues while writing my book. <em>They</em> considered themselves Unity experts, i suppose, and why not? They <em>had</em> actually finished some games with it. i remember one particular tweet that went something like this:</p>
<blockquote><p>Colleague: i&#8217;m going to do open heart surgery, but i&#8217;ve never trained to be a doctor.</p></blockquote>
<p>Of course, his error was in comparing Unity to open heart surgery.  Unity reminds me a lot of Flash &#8230; and not even Flash CSX, but Flash 4 back when i started in 2000. It strips out the whole mystery of writing code to draw stuff on the screen.  If you&#8217;ve had any experience with XNA and wished you could actually see and manipulate your 3D models, you&#8217;ll find Unity a real treat.  </p>
<p>Put another way: if coding to the metal is open heart surgery, working with Unity is cutting a heart out of construction paper using safety scissors.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/heart.jpg" alt="Heart"></p>
<p>Oh God &#8230; so much blood &#8230;
</p></div>
<h2>Gag Me</h2>
<p>If writing a beginner-friendly book was my first mandate, my secondary goal was to write a technical manual that wasn&#8217;t so damned serious as everything else i&#8217;d read. You&#8217;re learning how to make <em>video games</em>.  Why does everything have to read like a Terms of Service agreement?</p>
<p>i&#8217;m a fan of an O&#8217;Reilly series called HeadFirst, which is filled with cartoons and crossword puzzles and pictures &#8211; the idea being that if you are engaged on multiple levels in a variety of different ways, you&#8217;ll retain the material better than straight-up reading block after block of text.  (You can probably tell by now that i&#8217;m a big fan of breaking up text with bullet lists and pictures)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/monorailCat.jpg" alt="Monorail cat"></p>
<p>(why, look &#8211; there&#8217;s one now)
</p></div>
<p>i&#8217;d love to work on a HeadFirst book one day.  For now, as Packt is a small and relatively new publisher, i had to eschew the stock photography and crossword puzzles.  But what i could do, and what David requested i do, was to pepper the text with humour.  David wanted the same sense of humour i forcibly inject into this blog to bleed into the book.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/ouchy.jpg" alt="Ouchy the Clown"></p>
<p>You&#8217;ll laugh and you&#8217;ll LIKE it.
</p></div>
<p>One of the book&#8217;s technical reviewers apparently didn&#8217;t get the memo.  Throughout the drafts of the first two chapters, he filled the page up with comments like &#8220;please cut the humour &#8211; this is a technical manual, not the Muppet Show&#8221;, and &#8220;Well I <em>never</em>!&#8221;  i think i even counted one or two &#8220;harrumphs&#8221; in there.  It was like Packt had hired that wealthy dowager whose house the Three Stooges paint to review my book.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/dowager.jpg" alt="Wealthy dowager"></p>
<p>Well, it&#8217;s a fine day to buy a computer book, isn&#8217;t it Mr. Picklefeather?
</p></div>
<p>i re-connected with David.  This reviewer seemed pretty peeved.  Did i really have to go through the whole book and strip out all of the witty asides and punny paragraph headings?  That would be like taking the red nose and seltzer bottle away from a clown.  And then giving him colon cancer.</p>
<p>It got cleared up in short order.  i&#8217;m not sure Packt even kept that reviewer on for the remainder of the project, and in the end, humour won out.</p>
<h2>Currying Favour</h2>
<p>Packt maintains a staff in India, who were responsible for copy-editing the book.  You may have heard about the cultural growing pains of outsourcing work to foreign countries?  While it was far from a nightmare, i did find myself going to bat more than once for various cultural references or turns of phrase that didn&#8217;t make sense to my editor from Mumbai &#8211; especially whenever i bent the rules of grammar, spelling, and punctuation for the sake of the yuks.</p>
<p>For example:</p>
<blockquote><p>Worst. Game. Evar.</p></blockquote>
<p>was corrected to read</p>
<blockquote><p>Worst Game Ever</p></blockquote>
<p>i had to do the legwork to explain that, well, there&#8217;s this character on the once-popular teevee program The Simpsons, you see, and he enjoys comic books &#8230;  </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/comic.jpg" alt="Comic book guy"></p>
<p>Jokes are so much funnier when you have to explain them.
</p></div>
<p>Explaining why the word &#8220;evar&#8221; had to be spelled that way was even more of a challenge.  Many of our email volleys ended with &#8220;just leave it cuz it&#8217;s funnier that way.&#8221;  After she edited &#8220;cuz&#8221; to &#8220;because&#8221; for spite, i usually won out.  ;) </p>
<div class="displayed">
<p><a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881"><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/unity3dGameDevelopmentByExample.jpg" alt="Unity 3D Game Development By Example"></a></p>
</div>
<p>The result is a book that i&#8217;m very, very proud of: one that makes a great introduction to Unity, 3D graphics, game programming and design, and in a way that encourages the reader to start small, finish something (even if it&#8217;s terrible!), and slowly build up those skills until he&#8217;s ready to release his opus.  <b>Unity 3D Game Development By Example</b> is <a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881">well worth buying</a>.  And the best news of all? i even managed to sneak in a few dick jokes.</p>
<h2>Carpe Judex</h2>
<p>My grandfather worked as a bailiff in Thunder Bay Ontario.  Once day in the courtroom, there was a man brought in who had a dispute with his wife.  In the middle of the hearing, he stood up and drew his gun.  He shot and killed his wife, the judge, and his lawyer, before turning the gun on himself.  The last two men standing were my grandfather and the court stenographer.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_03_29/chalk.jpg" alt="Chalk outline"></p>
<p>See? It all comes full circle.
</p></div>
<p>Thunder Bay needed a judge.  My grandfather the bailiff, who to my knowledge had had no formal judiciary or legal training, was appointed to the position.  He became a popular judge of young offenders, and there&#8217;s a building in Thunder Bay across from the University that&#8217;s named after him.</p>
<p>Many colleges and Universities now offer programs in video game development, as well as golf course management, creative writing, and even stand-up comedy (!).  Don&#8217;t let the burden of a lack of training or experience get in the way of what you want to do.  Get a job making video games even though you&#8217;ve never made one.  Write a book, even though you&#8217;ve never written one and don&#8217;t know the subject matter.  <em>Perform open heart surgery</em> even though you&#8217;re not a &#8220;doctor&#8221; (whatever <em>that</em> means).  Recognize when the swirling twin tornadoes of chance and opportunity settle on your house, and get swept up.  Otherwise, you&#8217;ll be lying on your death bed wondering what might have been.</p>
<p>And let&#8217;s hope to God you&#8217;re not in for heart disease.   </p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F03%2F29%2Fi-wrote-a-book%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F03%2F29%2Fi-wrote-a-book%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/03/29/i-wrote-a-book/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3557&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/03/29/i-wrote-a-book/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Pimp My Portal: Introduction</title>
		<link>http://www.untoldentertainment.com/blog/2011/01/31/pimp-my-portal-introduction/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/01/31/pimp-my-portal-introduction/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 03:05:11 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Pimp My Game]]></category>
		<category><![CDATA[Pimp My Portal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3390</guid>
		<description><![CDATA[One of the most popular series of articles i&#8217;ve ever written was called Pimp My Game. It was an experiment in game monetization, back before i&#8217;d ever released a game of my own. i wanted to know how much money i could earn distributing a game, so that i&#8217;d know the amount of money i [...]]]></description>
			<content:encoded><![CDATA[<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/pimpMyPortalSmall.png" alt="Pimp My Portal">
</div>
<p>One of the most popular series of articles i&#8217;ve ever written was called <a href="http://www.untoldentertainment.com/blog/feature-articles/pimp-my-game/">Pimp My Game</a>.  It was an experiment in game monetization, back before i&#8217;d ever released a game of my own.  i wanted to know how much money i could earn distributing a game, so that i&#8217;d know the amount of money i could invest in development in order to break even, at the very least.</p>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/feature-articles/pimp-my-game/"><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/graph.jpg" alt="Pimp My Game"></a>
</div>
<p>The results were &#8230; abysmal. The <b>Pimp My Game</b> feature predates a number of tools and tricks that have made it far more possible for Flash game developers to earn money on their creations &#8211; most notably <a href="http://www.flashgamelicense.com">Flash Game License</a> and microtransactions (<a href="http://www.gamersafe.com">GamerSafe</a>/<a href="http://www.heyzap.com">HeyZap</a>/<a href="http://www.mochicoins.com">Mochi Coins</a>).</p>
<p>Even <em>with</em> those services, it struck me that the amount of money required to develop a game of significant scope and scale to catch the attention of the average portal-goer, versus the relative risk of <em>not</em> landing a large enough sponsorship or earning cash back through scant ad rev share, was not a racket i really wanted to be in.  Untold Entertainment makes custom games as a service for a number of clients, and i feel we&#8217;re paid appropriately for our efforts.  i&#8217;ve never developed a game for a client on the <em>off chance</em> that they&#8217;d pay money for it.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/constructionCrew.jpg" alt="Pimp My Game"></p>
<p>&#8220;Hopefully, we&#8217;ll land a great sponsorship once we&#8217;re finished paving this road.&#8221;
</p></div>
<p>i&#8217;ve been told numerous times, not least of all by the <b>Flash Game License</b> operators themselves, that game sponsorships can get up into five figures, with $20 000 being thrown around most often by people trying to impress me.  Who&#8217;s paying these sponsorships?  The buyers are mostly game portal owners.</p>
<h2>The Cake is a Lie</h2>
<p>What&#8217;s a game portal?  It&#8217;s a websites that aggregate games and sandbags them with assloads of ads.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/jacksmack.jpg" alt="Pimp My Game"></p>
<p><a href="http://www.jacksmack.com">Jacksmack.com</a> is a typical free-to-play Flash games portal.
</div>
<p>So a portal can pay out $20k to sponsor a game.  What&#8217;s in it for the portal?  Usually, portals require the game developers to incorporate the hyperlinked portal logo in the game pre-roll, and possibly other promotional hooks &#8211; a &#8220;more games&#8221; button on the title screen leading back to the portal, portal-specific high scores &#8211; that sort of thing.  The idea is that players play these free Flash games, which are distributed far and wide to tens of thousands of sites, and the players may purposely (or inadvertently) click somewhere in the game to be brought to the sponsoring portal.  Sponsors will often pay extra cash for exclusivity rights.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/gimme5.jpg" alt="Gimme5Games"></p>
<p><a href="http://www.gimme5games.com">Gimme5Games</a> is known as a high-rolling sponsor in the Flash game developer community.
</div>
<p>And how does the portal make enough money to pay a sponsorship? Unless i&#8217;m missing something, the most significant source of revenue for a game portal is advertising.  There are some smaller, secondary streams &#8211; for example, Mochimedia kicks 10% of Mochi Coins sales to the portal when players spend Mochi Coins in games hosted on those portals, and Mochi also cuts the portal in for a small percentage of Mochiads revenue, but there we&#8217;re talking about fractions of fractions of pennies. The bread and butter of any games portal is advertising.</p>
<h2>If You Can&#8217;t Beat &#8216;Em &#8230; </h2>
<p>At this point i began eyeing the portals themselves with keen interest.  $20 000 for a sponsorship?  Again, unless i&#8217;m missing something, that must mean that at some point, a portal earns <em>more</em> than $20k in advertising.  And game portal advertising revenue is <em>passive</em> income, that elusive majestic money creature that i&#8217;m constantly persuing. You just have to throw up a portal, stick some games on there, surround the games with ads, and kick back while waves of money roll over you like a stinky cash tsunami.  &#8220;Beautiful&#8221;, i thought. &#8220;Let&#8217;s do this thing.&#8221;</p>
<p>Here are the steps i followed to set up my first portal, <a href="http://www.wordgameworld.com">WordGameWorld.com</a>:</p>
<ol>
<li>Register the domain name &#8211; $10
<li>Pay for hosting.  i&#8217;m paying $33/mo to a company called 1&#038;1 to host a VPS (Virtual Private Server), which is essentially like having my own (underpowered) web server computer.  i originally started renting the VPS so that we could power <a href="http://www.interruptingcowtrivia.com">Interruping Cow Trivia</a> using the multiplayer ElectroServer software.  You can probably get away with paying a regular web host less than $10/mo to host a portal.
<li>Install <a href="http://www.wordpress.com">WordPress</a>, which is very popular free blog software. The Untold Entertainment blog you&#8217;re reading now runs on WordPress.
<li>Purchase a <a href="http://wparcade.com/">WPArcade</a> theme and plugin.  These guys license a WordPress theme (skin) that makes your site look like a game portal.  The plugin they provide enables you to enter the game distribution rss feed address from MochiMedia and, with the click of a button, inject ten thousand free Flash games into your portal site.
<li>Set up a <a href="http://www.adsense.com">Google Adsense</a> account.  This was the trickiest step &#8211; at first, Google denied my registration because <a href="http://www.wordgameworld.com">WordGameWorld.com</a> had zero traffic.  WordGameWorld.com was live for a long time with no advertising, until i got a hot tip from a Twitter friend that once Adsense approved <em>one</em> of my sites, i could use Adsense ads on other sites that i owned.  i leveraged the traffic on UntoldEntertainment.com to get my account approved, and then placed the ads around the WPArcade WordPress theme using their tool.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/wordGameWorldLogo_150x150.png" alt="WordGameWorld.com"></p>
<p><a href="http://www.untoldentertainment.com/blog/2010/03/22/untold-entertainment-joins-the-dark-side/">Read more about the curation, cross-promotion and niche focus rationale behind WordGameWorld.com</a>
</div>
<h2>Step 4: Proft?</h2>
<p>At this point, i had contractors come in to widen my front door in anticipation of the deluge of cash that would no doubt come blasting into my living room from men with money guns, all owing to this most brilliant idea of mine.  It wasn&#8217;t long before i figured out that setting up a game portal is easy &#8230; driving traffic to it ain&#8217;t.</p>
<p>For the remainder of this series, i&#8217;ll document my madcap methods i used to try to drive traffic to my game portals.  My journey takes me from dating services for gay nerds, to bikini-clad women in Brazil, to the very bowels of The Internatz itself &#8230; all in the name of making money off the backs of the free Flash game developers that i never want to become.  i promise it will be lurid, sleazy, and informative.  But mostly lurid.</p>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/pimp-my-portal/"><img src="http://www.untoldentertainment.com/blog/img/features/pimpMyPortal/pimpMyPortalSeries.jpg" alt="Pimp My Portal"></a>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F01%2F31%2Fpimp-my-portal-introduction%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F01%2F31%2Fpimp-my-portal-introduction%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/01/31/pimp-my-portal-introduction/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3390&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/01/31/pimp-my-portal-introduction/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Convert Artwork from Flash to Illustrator</title>
		<link>http://www.untoldentertainment.com/blog/2011/01/26/how-to-convert-artwork-from-flash-to-illustrator/</link>
		<comments>http://www.untoldentertainment.com/blog/2011/01/26/how-to-convert-artwork-from-flash-to-illustrator/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 15:42:59 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3385</guid>
		<description><![CDATA[A client recently asked me if i could supply him with artwork from a game so that another team could produce a video. The video team, of course, couldn&#8217;t/wouldn&#8217;t do anything with the native .fla (Flash) files i had on hand. They wanted Illustrator files. It took a lot of back and forth and futzing [...]]]></description>
			<content:encoded><![CDATA[<p>A client recently asked me if i could supply him with artwork from a game so that another team could produce a video.  The video team, of course, couldn&#8217;t/wouldn&#8217;t do anything with the native .fla (Flash) files i had on hand.  They wanted Illustrator files.</p>
<p>It took a lot of back and forth and futzing to finally convert the artwork properly, and when i finally found the solution, i realized i had known it all along and had merely forgotten it (because i don&#8217;t do this type of thing often).  So i&#8217;m recording the solution here for posterity; the next time i have to do this, a Google search will turn up my own blog :)  It actually wouldn&#8217;t be the first time that&#8217;s happened.</p>
<p>i&#8217;ll keep you on tenterhooks and take you through the frustrating conversion process, just so that you can swear along with me and nod your head and say &#8220;yep &#8211; that&#8217;s happened to me.&#8221;</p>
<h2>Export Image</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/characters1.jpg" alt="Characters"></p>
<p>These are the Flash vector characters the client needed me to convert.
</p></div>
<p>The ability to export artwork to .ai format has actually been removed from Flash Professional as of version CS5, and has been replaced with the Adobe .fxg format, which works as expected. The .fxg format even converts gradients properly, which have been a longstanding asspain for the past 10 years.  If you&#8217;re running CS5 or better, export to .fxg and you&#8217;re done.  If you&#8217;re trapped in CS4 or below, here&#8217;s what you may have tried:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/export.jpg" alt="Export Image">
</div>
<ol>
<li>File > Export > Export Image
<li>Choose Adobe Illustrator (*.ai) from the drop-down filetype list
<li>Punch in a filename, and click &#8220;Save&#8221;
<li>Open the file in Illustrator
</ol>
<p>The first roadblock you encounter may be this message:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/error.jpg" alt="Can't open the illustration.">
</div>
<blockquote><p>Can&#8217;t open the illustration.  The illustration contains an incomplete or garbed object description.</p>
<p>Offending operator: &#8220;&#8221;</p>
<p>Adobe_Illustrator_AI5 / initialize get exec<br />
%%BeginEncoding: _pixelmic &#8230; feh.  i can&#8217;t be arsed to look up the accented characters to type the rest.</p></blockquote>
<p>i&#8217;ve ranted at length before about the error messages eggheads put into their software products.  How on Earth is joe average user &#8211; and an <em>artist</em>, at that &#8211; supposed to react to and troubleshoot a message like this?</p>
<p>Obviously (?), all the egghead wanted the artist to do was this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/characters2.jpg" alt="Characters">
</div>
<p>Select the single movieclip and press CTRL+B to break apart the object into separate objects.  Now, when i go through the export process and bring the file into Illustrator, i get this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/desaturated.jpg" alt="Characters"></p>
<p>Um &#8230; yuck?  Who sucked all the color out?
</p></div>
<p>The reason why the colors are desaturated and grey-looking apparently has to do with the Flash .ai export routine deciding to convert RGB artwork to CMYK artwork.  i don&#8217;t know why it does this, but it&#8217;s not helpful.  But at least the artwork is in Illustrator in vector format, right?</p>
<p>At this point, you <em>could</em> pick through every piece of vector art and tweak the color by hand &#8230; if you&#8217;re a sucker.  Instead, let&#8217;s get on to the reason you&#8217;re here: the actual solution to this non-working nonsense.</p>
<h2>WMF FTW!</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/wmf.jpg" alt="WMF"></p>
<p>The mighty (and seldom-understood) wmf
</p></div>
<p>The secret is to export as a Windows Metafile.  Mac people, i don&#8217;t know if you have this option.  If not, i&#8217;m not sure how to help you &#8230; but once you counter-intuitively export as a .wmf file instead of an .ai file and bring THAT into Illustrator, voila: your artwork is beautifully preserved with its RGB colors intact.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/characters3.jpg" alt="Characters"></p>
</div>
<p>As i mentioned, the one drawback is that gradients don&#8217;t survive the crossing.  This character&#8217;s cell phone casts an alpha gradient glow across her face, which shows up as a flat white polygon in Illustrator:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2011_01_26/gradient.jpg" alt="Gradient">
</div>
<p>.fxg format will fix that. If you&#8217;re not ready to upgrade your software, this might entail an ugly hand-conversion process of all your gradients &#8230; unless someone else has discovered the esoteric conversion secret to preserving gradients?  Anyone?</p>
<p>Big thanks to Gavin Friesen, my Art Director back at Corus, for originally cluing me in to this solution.</p>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature.
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F01%2F26%2Fhow-to-convert-artwork-from-flash-to-illustrator%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2011%2F01%2F26%2Fhow-to-convert-artwork-from-flash-to-illustrator%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2011/01/26/how-to-convert-artwork-from-flash-to-illustrator/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3385&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2011/01/26/how-to-convert-artwork-from-flash-to-illustrator/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Dynamically Add a GameObject to the Scene in Unity 3D</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/23/dynamically-add-a-gameobject-to-the-scene-in-unity-3d/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/23/dynamically-add-a-gameobject-to-the-scene-in-unity-3d/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 22:43:07 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3335</guid>
		<description><![CDATA[If you work a lot in Flash, you&#8217;re used to the process of adding a linkage name to a MovieClip in the library, and then using the new keyword and addChild method to dynamically pull the clip out of the library and display it on the stage. You can do something very similar in Unity [...]]]></description>
			<content:encoded><![CDATA[<p>If you work a lot in Flash, you&#8217;re used to the process of adding a linkage name to a MovieClip in the library, and then using the <b>new</b> keyword and <b>addChild</b> method to dynamically pull the clip out of the library and display it on the stage.</p>
<p>You can do something very similar in Unity 3D, but the process is slightly different.  Be sure to read our <a href="http://www.untoldentertainment.com/blog/2010/12/21/flash-to-unity-3d-glossary/">Flash to Unity 3D Glossary</a> if you&#8217;re coming over to Unity 3D from Flash.</p>
<h2>1. Create the GameObject</h2>
<p>We&#8217;ll make it real simple.  Click GameObject > Create Other > Cube in the menus to add a cube primitive to the Scene.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/createCube.jpg" alt="Create a Cube Primitive in Unity 3D"></p>
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/cube.jpg" alt="Cube Primitive in Unity 3D"></p>
<p>A cube appears somewhere in your Scene&#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/hierarchy.jpg" alt="Cube Primitive in the Hierarchy panel in Unity 3D"></p>
<p>&#8230; and the Cube GameObject is listed in the Hierarchy.
</p></div>
<h2>2. Create an Empty Prefab</h2>
<p>A Prefab is a lot like a Flash MovieClip.  It&#8217;s going to contain our Cube GameObject.  To create the Prefab, click the Create button in the Project panel, and choose Prefab from the resulting menu.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/createButton.jpg" alt="Unity 3D Project Panel Create Button"></p>
<p>Click here &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/prefabMenu.jpg" alt="Unity 3D Project Panel Prefab Menu"></p>
<p>and then here &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/emptyPrefab.jpg" alt="Unity 3D Project Panel Empty Prefab"></p>
<p>&#8230; to get this.
</p></div>
<p>Right/alternate-click on the Prefab, or click and hold (Mac)/press F2 (PC) to rename the Prefab.  I called mine &#8220;Cube&#8221;.  This won&#8217;t create a naming conflict or anything.</p>
<h2>3. Click/drag the Cube into the Prefab</h2>
<p>Click and drag the Cube GameObject from the Hierarchy panel into the empty grey Prefab you just created in the Project panel.  The Prefab lights up blue to indicate that it&#8217;s got junk in the trunk.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/bluePrefab.jpg" alt="Unity 3D Project Panel Full Prefab"></p>
</div>
<p>It&#8217;s now safe to delete the Cube GameObject from the Scene (via the Hierarchy panel) by highlighting it and pressing Delete (PC) or CMD+Delete (Mac).  The Cube is safe and sound inside the Prefab.</p>
<h2>4. Create a new Javascript</h2>
<p>Our Cube Prefab is ready to be instantiated (instantiate == make an instance [copy] of).  Let&#8217;s create a javascript to do the instantiating.  In the Project panel, click Create > Javascript to make a new script.  </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/createButton.jpg" alt="Unity 3D Project Panel Create Button"></p>
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/newJavascript.jpg" alt="Unity 3D Project Panel New Javascript"></p>
</div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/newBehaviourScript.jpg" alt="Unity 3D Project Panel New Javascript"></p>
</div>
<p>Name the javascript something sensible.  <b>Then, click/drag the script onto the Main Camera.</b>  (We do this because our script won&#8217;t execute unless it&#8217;s hooked up to a GameObject in the Scene.)</p>
<h2>5. Store a Reference to the Prefab</h2>
<p>This is the fanciest/weirdest thing we&#8217;ll do in the entire tutorial.</p>
<p>Double-click the script to open it up in Unitron or Uniscite (depending on whether you have a Mac or a PC).</p>
<p>Declare a variable at the top of the script called myCube:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myCube <span style="color: #339933;">:</span> GameObject<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Save the script and close the editor.</p>
<p>In order to store a reference to the cube Prefab, we need to click and drag it into the variable we just created.</p>
<p>In the Hierarchy panel, click on the Main Camera, which is the GameObject to which we attached our script.</p>
<p>In the Inspector panel, look for the script component.  You&#8217;ll see the myCube variable we created, and next to it is a piece of text that says None (Game Object)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/none.jpg" alt="Unity 3D Variable"></p>
<p>What in the Hells?
</p></div>
<p>myCube is the name of the variable (bucket), and the None (Game Object) is where the value goes.</p>
<p>Now, you need to <em>click and drag</em> the Cube Prefab from the Project panel into that value area that i&#8217;ve highlighted. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/clickDrag.jpg" alt="Unity 3D Click n' Drag"></p>
</div>
<p>This is the result:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/result.jpg" alt="Unity 3D Variable"></p>
<p>This is going to take some getting used to.
</p></div>
<p>It&#8217;s weird.  i know.</p>
<p><b>NOTE:</b> You called the variable &#8220;myCube&#8221;, but it gets displayed in the IDE as &#8220;My Cube&#8221;.  Why is that?  Chalk it up to a Unity idiosyncrasy that i&#8217;m not a huge fan of.  Check the script.  Your variable is still called &#8220;myCube&#8221; where it counts. </p>
<h2>6. Instantiate the Prefab</h2>
<p>Now, with a reference to that Prefab, you&#8217;re all ready to go.  Double-click to edit your script again, and punch in the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myCube <span style="color: #339933;">:</span> GameObject<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> pos <span style="color: #339933;">:</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this is where the Cube will appear when it's instantiated</span>
     <span style="color: #003366; font-weight: bold;">var</span> rot <span style="color: #339933;">:</span> Quaternion <span style="color: #339933;">=</span> Quaternion.<span style="color: #660066;">identity</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Quaternion.identity essentially means &quot;no rotation&quot;</span>
     Instantiate<span style="color: #009900;">&#40;</span>myCube<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> rot<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// The Instantiate command takes a GameObject, a Vector3 for position and a Quaternion for rotation.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Gettin&#8217; Fancy</h2>
<p>If you&#8217;ve read our article <a href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/">Understanding Loops with Arrays</a>, you might have a notion of how to use Loops and Arrays to instantiate an armada of Prefabs into your scene.  Here&#8217;s some sample code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> myCube <span style="color: #339933;">:</span> GameObject<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// Store a bunch of different positions in an Array:</span>
     <span style="color: #003366; font-weight: bold;">var</span> aPositions <span style="color: #339933;">:</span> Array <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                      <span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                      <span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                      <span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                      <span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> rot <span style="color: #339933;">:</span> Quaternion <span style="color: #339933;">=</span> Quaternion.<span style="color: #660066;">identity</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #006600; font-style: italic;">// Loop as many times as there are elements in the aPositions Array:</span>
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>aPositions.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
          Instantiate<span style="color: #009900;">&#40;</span>myCube<span style="color: #339933;">,</span> aPositions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> rot<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Put a new cube on the screen using the i'th position   </span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/armada.jpg" alt="Unity 3D Instantiation"></p>
<p>Here&#8217;s what it looks like.
</p></div>
<h2>One More for the Road</h2>
<p>Just for kicks, here&#8217;s a script that&#8217;ll throw the cubes on the screen any old place, using Random.Range():</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> myCube <span style="color: #339933;">:</span> GameObject<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// Let's store some minimum and maximum possible x,y and z values</span>
     <span style="color: #006600; font-style: italic;">// to position our cubes:</span>
     <span style="color: #003366; font-weight: bold;">var</span> minX <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> maxX <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> minY <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> maxY <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> minZ <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> maxZ <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
     <span style="color: #006600; font-style: italic;">// (you can fiddle with these numbers to change the range of possible spawn positions)</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> totalCubes <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> <span style="color: #CC0000;">50</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Change this to whatever number of cubes you'd like to have on-screen</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> rot <span style="color: #339933;">:</span> Quaternion <span style="color: #339933;">=</span> Quaternion.<span style="color: #660066;">identity</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>totalCubes<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
          <span style="color: #006600; font-style: italic;">// Use Random.Range to grab randomized x,y and z values within our min/max ranges:</span>
          <span style="color: #003366; font-weight: bold;">var</span> randomX <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> Random.<span style="color: #660066;">Range</span><span style="color: #009900;">&#40;</span>minX<span style="color: #339933;">,</span> maxX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #003366; font-weight: bold;">var</span> randomY <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> Random.<span style="color: #660066;">Range</span><span style="color: #009900;">&#40;</span>minY<span style="color: #339933;">,</span> maxY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #003366; font-weight: bold;">var</span> randomZ <span style="color: #339933;">:</span> int <span style="color: #339933;">=</span> Random.<span style="color: #660066;">Range</span><span style="color: #009900;">&#40;</span>minZ<span style="color: #339933;">,</span> maxZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #003366; font-weight: bold;">var</span> pos <span style="color: #339933;">:</span> Vector3 <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Vector3<span style="color: #009900;">&#40;</span>randomX<span style="color: #339933;">,</span> randomY<span style="color: #339933;">,</span> randomZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          Instantiate<span style="color: #009900;">&#40;</span>myCube<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> rot<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Put a new cube on the screen using a randomized position   </span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_23/randomCubes.jpg" alt="Unity 3D Random Instantiation"></p>
<p>Awesomazing.
</p></div>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F23%2Fdynamically-add-a-gameobject-to-the-scene-in-unity-3d%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F23%2Fdynamically-add-a-gameobject-to-the-scene-in-unity-3d%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/23/dynamically-add-a-gameobject-to-the-scene-in-unity-3d/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3335&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/23/dynamically-add-a-gameobject-to-the-scene-in-unity-3d/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Make Something Clickable in Unity 3D</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/22/make-something-clickable-in-unity-3d/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/22/make-something-clickable-in-unity-3d/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 05:20:51 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3332</guid>
		<description><![CDATA[Making a GameObject clickable in Unity 3D is a piece of cake! Just write an OnMouseDown function in a script, and stick it to your GameObject. Voila &#8211; instant interactivity! // Unity javascript function OnMouseDown&#40;&#41; &#123; // Do something &#125;]]></description>
			<content:encoded><![CDATA[<p>Making a GameObject clickable in Unity 3D is a piece of cake!  Just write an OnMouseDown function in a script, and stick it to your GameObject.  Voila &#8211; instant interactivity!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Unity javascript</span>
<span style="color: #003366; font-weight: bold;">function</span> OnMouseDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F22%2Fmake-something-clickable-in-unity-3d%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F22%2Fmake-something-clickable-in-unity-3d%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/22/make-something-clickable-in-unity-3d/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3332&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/22/make-something-clickable-in-unity-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn Something Invisible in Unity 3D</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/22/turn-something-invisible-in-unity-3d/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/22/turn-something-invisible-in-unity-3d/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 05:17:03 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3329</guid>
		<description><![CDATA[thing.renderer.enabled = true; // or false &#8230; where &#8220;thing&#8221; is a reference to a GameObject. If you&#8217;re doing this in a script that&#8217;s attached to the GameObject you want to hide, try: gameObject.renderer.enabled = false; Note that the GameObject&#8217;s collider is still active, so the GameObject can still be clicked on, run into, etc. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">thing.<span style="color: #660066;">renderer</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// or false</span></pre></div></div>

<p>&#8230; where &#8220;thing&#8221; is a reference to a GameObject.</p>
<p>If you&#8217;re doing this in a script that&#8217;s attached to the GameObject you want to hide, try:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">gameObject.<span style="color: #660066;">renderer</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that the GameObject&#8217;s collider is still active, so the GameObject can still be clicked on, run into, etc.  Here&#8217;s a fast way to make the GameObject&#8217;s collider inactive:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">gameObject.<span style="color: #660066;">collider</span>.<span style="color: #660066;">isTrigger</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></div></div>

<p>To disable the GameObject&#8217;s clickability, do this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">gameObject.<span style="color: #660066;">active</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F22%2Fturn-something-invisible-in-unity-3d%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F22%2Fturn-something-invisible-in-unity-3d%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/22/turn-something-invisible-in-unity-3d/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3329&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/22/turn-something-invisible-in-unity-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash to Unity 3D Glossary</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/21/flash-to-unity-3d-glossary/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/21/flash-to-unity-3d-glossary/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 04:54:47 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3321</guid>
		<description><![CDATA[If you&#8217;re thinking of transitioning from Flash to Unity 3D, you&#8217;re in luck: the two programs are very similar, and it shouldn&#8217;t take you very long to feel right at home. The biggest difference that i can see between the two is that Unity is a proper game engine, while Flash is a program that [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re thinking of transitioning from Flash to Unity 3D, you&#8217;re in luck: the two programs are very similar, and it shouldn&#8217;t take you very long to feel right at home.  The biggest difference that i can see between the two is that Unity is a proper game engine, while Flash is a program that you bully, beg and cajole into doing game-like things.  Want collisions, 3D depth-swapping, particle systems, physics, shaders, and a whole lot more right out of the box (instead of implementing Box 2D, Away 3D, Collision Detection Kit, and God knows what else)?  Unity is a real treat!</p>
<p>Here are a few glossary terms that kinda sorta carry over from Flash to Unity: </p>
<p>MovieClip == GameObject (but more accurately, Symbol == Prefab.  Much like a MovieClip/Graphic/Button in Flash, whatever changes you make to a Prefab in Unity will replicate to all instances of that Prefab)</p>
<p>Scene == Scene (but Scenes in Flash are generally useless and glitchy &#8230; Scenes in Unity are the bee&#8217;s knees)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/scenesUnity.jpg" alt="Unity 3D Scenes"></p>
<p>Unity.
</p></div>
<p>Library == Project panel</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/libraryFlash.jpg" alt="Flash Library"></p>
<p>Flash.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/projectPanelUnity.jpg" alt="Unity 3D Project Panel"></p>
<p>Unity.
</p></div>
<p>Properties panel == Inspector panel</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/propertiesFlash.jpg" alt="Properties panel in Flash"></p>
<p>Flash.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/inspectorUnity.jpg" alt="Inspector panel in Unity"></p>
<p>Unity.
</p></div>
<p>Timeline == A-NOTHING!!  (except that there IS a timeline that allows you to animate GameObjects.  The resulting animation is stored in an .anim file inside your Project panel.  You can apply an animation to any GameObject in your Scene, so animations are curiously reusable)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/timelineFlash.jpg" alt="Timeline in Flash"></p>
<p>Flash.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/timelineUnity.jpg" alt="Timeline in Unity 3D"></p>
<p>Unity. (warning: the UX [user experience] on this thing kind of blows ass.)
</p></div>
<p>Instance names == tags &#8230; sorta (but unlike in Flash, you can have multiple GameObject instances with the same tag)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/instanceNamesFlash.jpg"></p>
<p>Flash.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/tagsUnity.jpg"></p>
<p>Unity.
</p></div>
<p>Layers == layers (but Unity does not display its layers in anything nearly as nice as the Flash timeline)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/layersFlash.jpg"></p>
<p>Flash.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/layersUnity.jpg"></p>
<p>Unity.
</p></div>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F21%2Fflash-to-unity-3d-glossary%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F21%2Fflash-to-unity-3d-glossary%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/21/flash-to-unity-3d-glossary/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3321&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/21/flash-to-unity-3d-glossary/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to Start a Game Project in Unity 3D</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/21/how-to-start-a-game-project-in-unity/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/21/how-to-start-a-game-project-in-unity/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 04:18:24 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3312</guid>
		<description><![CDATA[By default, a new Unity install opens with a demo project. Unity 2.6 had an island, while Unity 3.0 has a G.I. Joe-style first-person shooter game. Follow these steps to start your own game project from scratch in Unity; 1. Start a New Project Click File > New Project &#8230; Every Unity sits in its [...]]]></description>
			<content:encoded><![CDATA[<p>By default, a new Unity install opens with a demo project.  Unity 2.6 had an island, while Unity 3.0 has a G.I. Joe-style first-person shooter game.  Follow these steps to start your own game project from scratch in Unity;</p>
<h2>1. Start a New Project</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/newProject.jpg" alt="New project in Unity"></p>
<p>Click File > New Project &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/projectWizard.jpg" alt="Project Wizard in Unity"></p>
</div>
<p>Every Unity sits in its own folder.  In this dialogue, browse to or create a new folder where your project will live, and then click the Create button.</p>
<p>What you&#8217;re left with is this:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/blankUnityProject.jpg" alt="Blank Project in Unity"></p>
<p>Ok &#8211; where&#8217;s the &#8220;Make Game&#8221; button at?
</p></div>
<p>Here&#8217;s what&#8217;s going on behind the scenes:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/projectFolder.jpg" alt="Unity Project Folder"></p>
</div>
<p>Unity automatically creates three sub-folders in your Project folder.  You won&#8217;t have to touch these folders &#8211; in fact, you really shouldn&#8217;t, because there&#8217;s metadata in there that might get botched if you start poking around.  Most of the time, you can import assets directly through the Unity IDE (program).</p>
<h2>2. Make a Scene</h2>
<p>Unity Projects are comprised of Scenes.  In Flash, it wasn&#8217;t really a good idea to use the Scenes, but in Unity, it&#8217;s darn near a requirement.  What you&#8217;re looking at now is actually an unnamed Scenes.  Scenes must be saved individually &#8230; whenever you try to leave one Scene to look at another, you&#8217;ll get a Save Confirmation prompt.</p>
<p>The smartest thing to do right off the bat is to save this Scene.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/saveSceneAs.jpg" alt="Unity Save Scene As"></p>
<p>Go to File > Save Scene as &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/sceneName.jpg" alt="Unity Scene Name"></p>
</div>
<p>Choose a name for your Scene.  Some really simple examples are &#8220;Title&#8221;, &#8220;Credits&#8221;, &#8220;Win&#8221;, &#8220;Lose&#8221;, and &#8220;Game&#8221; for an extremely basic project.  i&#8217;m calling this one &#8220;Game&#8221;, which is where all my main game action will take place.</p>
<p>Once you hit &#8220;Save&#8221;, two wonderful things will happen:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/titleBar.jpg" alt="Unity Title Bar"></p>
<p>The name of your new Scene is reflected in the Title Bar of your project &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/projectPanel.jpg" alt="Unity Project Panel"></p>
<p>.. and a new Scene shows up in your Project panel.
</p></div>
<p>The Project panel is where all your <em>stuff</em> goes.  It&#8217;s very much like the Library in Flash.  Scenes have a little Unity 3D icon next to them.  </p>
<h2>Put Your Scene in a Folder</h2>
<p>The final thing you&#8217;ll want to do is to create a folder for your Scenes, and dump your Scene inside it. </p>
<p>At the top of the Project panel, click the Create button and choose &#8220;Folder&#8221;:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/createButton.jpg" alt="Unity Project Panel Create Button"></p>
<p>This button sees a lot of use in Unity.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/createFolder.jpg" alt="Unity Project Panel Create Folder"></p>
<p>While you&#8217;re here, check out all the other cook junk you can build.
</p></div>
<p>You can also right click or alternate click on the Project panel to bring up this menu.  Mac users can probably splat-click or some nonsense.</p>
<p>And then:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/projectPanelScenesFolder.jpg" alt="Unity Project Panel Scenes Folder"></p>
<p>Rename the folder &#8220;Scenes&#8221; by right/alternate-clicking, slow double-clicking (Mac) or pressing F2 (PC)
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_21/sceneInFolder.jpg" alt="Unity Project Panel Game Scene in Folder"></p>
<p>Drag and drop the Game Scene inside the folder. Click the grey arrow to see what&#8217;s inside the folder.
</p></div>
<h2>What Now?</h2>
<p><b>How do i learn Unity 3D?</b></p>
<p>To learn more about developing games for Unity 3d and to learn the basic controls for getting around the program, read the first chapter of my book <a href="http://www.packtpub.com/article/introduction-to-game-development-using-unity-3d">Unity 3D Game Development by Example</a>.  Next, buy four copies of the book (in case you accidentally drop three of them in the mud).</p>
<p><b>How do i build a timer in Unity?</b></p>
<p>When you&#8217;re a little further along, read this sample of Chapter 7 of my book, <a href="http://www.packtpub.com/article/unity-3d-game-development-dont-be-clock-blocker">Don&#8217;t be a Clock Blocker</a>.    That&#8217;s how.</p>
<p><b>How do i program in Unity?</b></p>
<p>If you need a little help with programming in Unity using javascript, read our <a href="http://www.untoldentertainment.com/blog/unity-nuub/">Understanding Programming in Unity Javascript</a> series.</p>
<p><b>How do i transition from Flash to Unity?</b></p>
<p>Check out our article on Five Common AS3 to UnityScript Translations.</p>
<p><b>Alright &#8211; what else you got?</b></p>
<p>Like our style?  For more free Unity 3D tutorials, sign up for our <a href="http://www.untoldentertainment.com/blog/unity-3d-game-development-by-example/"><b>Unity 3D Game Development by Example</b> newsletter</a>, and we&#8217;ll send out a link whenever we post a new tutorial or article on Unity 3D.</p>
<p>Go forth and game!</p>
<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F21%2Fhow-to-start-a-game-project-in-unity%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F21%2Fhow-to-start-a-game-project-in-unity%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/21/how-to-start-a-game-project-in-unity/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3312&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/21/how-to-start-a-game-project-in-unity/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Understanding Functions &#8211; Return Values</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/03/understanding-functions-return-values/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/03/understanding-functions-return-values/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 15:27:20 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3259</guid>
		<description><![CDATA[There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Functions are one of them. In Understanding Functions, we learned that Functions are a way to bundle code statements together into a tight little unit that we can invoke (or “call”) any time [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Functions are one of them.</p>
<p>In <a href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/">Understanding Functions</a>, we learned that Functions are a way to bundle code statements together into a tight little unit that we can invoke (or “call”) any time we like, and as often as we like. There are two very important features to learn about Functions: <a href="http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/">Arguments</a> and Return Values. We’ll figure out Return Values in this article.</p>
<h2>One Fanta, Please</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/vending.jpg" alt="Vending Machine">
</div>
<p>We talked about how Functions that accept arguments require exact change. If a Function asks for a String, you have to pass (&#8220;pay&#8221;) it a String.  If it wants an int, you must pass it an int.  If it wants two Arrays, a String, and four ints, you have to pass it those seven datatypes in that exact order.  If you pass the right datatypes in the wrong order, if you pass the wrong datatypes altogether, or if you pass the wrong number of arguments, you&#8217;ll throw a (possibly cryptic) error.</p>
<p>So let&#8217;s imagine that Functions are kinda like vending machines.  They require exact change, even specifying the <em>types</em> of coins you need to pay (ie five nickels, NOT one quarter).  But what do we get for all our trouble?  A kick in the pants and we&#8217;re sent on our way, that&#8217;s what.  Wouldn&#8217;t it be great if Functions could actually <em>give back</em> to society, instead of being a drain on our charitable resources?</p>
<p>Thanks to <b>return values</b>, they can.  A return value is the can of Coke that the Function vending machine spits out when we plug in our coins.   </p>
<p>Just as we type (specify a datatype for) our variables, we can also type our Functions.  When we do that, we&#8217;re saying &#8220;this is the type of thing the Function is going to return (give back/pay out/cough up).  Here&#8217;s how we write a Function that returns a String:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> giveMeGoodNewsOnly<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;good news&quot;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>There are a few moving parts involved here.  Let&#8217;s take it step by step.</p>
<p>The <em>type</em> of the return value goes at the end of the Function declaration.  We split it out using a colon (two dots), just like when we type a variable.  Here&#8217;s a punctuation refresher:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/punctuation.jpg" alt="Punctuation refresher">
</div>
<p>And here&#8217;s a representation of the Function using colour blocks, because colours are pretty:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/functionReturnValues.jpg" alt="Return Values">
</div>
<p>By adding that datatype to the end of our Function declaration, we&#8217;re making a promise: the Function will return (pay out/cough up) something that has that datatype.  To live up to that promise, we use the <b>return</b> keyword.  Return is the command that pays/spits out/coughs up a value.  In the code example above, the giveMeGoodNewsOnly Function is typed <b>String</b>, which means it must return a String.  In the statement block (between the curly braces), we use the <b>return</b> keyword to return a String.  And all was right with the world.</p>
<h2>Where Does the Return Type Go?</h2>
<p>So, fine &#8211; we <b>return</b> something from our Function.  But what happens to that value?  Remember when our Pac Man-like code interpreter chewed through the Function call, and packed his suitcase with the arguments?</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step1.jpg" alt="Call a Function"></p>
<p>The code interpreter recognizes this as a Function call &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step2.jpg" alt="Bring the Arguments"></p>
<p>&#8230; and takes the arguments with him in his suitcase.
</p></div>
<p>When the code interpreter finds the function, he unpacks the arguments into the parameters.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/unpack.jpg" alt="Unpack the arguments"></p>
</div>
<p>At this point, the code interpreter has an empty suitcase.  When he reaches a <b>return</b> statement, he packs the value into his suitcase.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/pack.jpg" alt="Pack the return value"></p>
<p>Get packing, Pac Man.
</p></div>
<p>As we saw earlier, the code interpreter returns to the next line after the original function call.  But this time, he&#8217;s got a suitcase packed with a return value:</p>
<p>
<object width="600" height="500">
<param name="movie" value="http://www.untoldentertainment.com/blog/img/2010_12_02/returnValueFlow.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="transparent"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="600" height="500" src="http://www.untoldentertainment.com/blog/img/2010_12_02/returnValueFlow.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" ></embed>
</object>
</p>
<p>(this is an interactive demonstration!  Keep clicking the &#8220;Next&#8221; button to follow the code interpreter through the example)</p>
<h2>Unpacking the Return Value</h2>
<p>When the code interpreter arrives from his journey with the return value in tow, we need to somehow capture that return value.  Otherwise, the interpreter just throws it away and it disappears into the either.</p>
<p>Here&#8217;s a simple example to demonstrate that concept:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #cc66cc;">6</span>+<span style="color: #cc66cc;">5</span>;</pre></div></div>

<p>You know and i know that 6+5 is 11. Your computer knows that too.  When you type that into a line of code, the computer adds 6 and 5.  And then &#8230;?  Nothing.  We haven&#8217;t told the computer to <em>do</em> anything with that result, so it&#8217;s a wasted piece of code.</p>
<p>Here are a couple of ways we can make use of the 11 result.  We can store the result in a variable (bucket), or we can trace the result to the output/console window:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> result : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">6</span>+<span style="color: #cc66cc;">5</span>; <span style="color: #808080; font-style: italic;">// Store the value 11 in a variable called &quot;result&quot;</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">6</span>+<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Print 11 to the output window</span></pre></div></div>

<p><b>Note:</b> Unity javascript users should use <b>print</b> or <b>Debug.Log</b> instead of <b>trace</b> to print to the <b>Console</b> window.</p>
<p>It&#8217;s the same issue with Functions and their return values.  If we call the sayHello Function and it returns a value, the value is going to disappear unless we capture it somehow.  Just like the 6+5 example, let&#8217;s store the return value in a variable, or print it to the output window:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> greeting : <span style="color: #0066CC;">String</span> = sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Jennifer&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Store the return value &quot;Hello, Jennifer&quot; in a variable called greeting</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Matthias&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Print Hello, Matthias to the output window</span></pre></div></div>

<p>The code interpreter needs some place to unpack his bags.  These are just two ways to capture the return value &#8211; there are many, many more.  For example, you can add the result to an Array using the Push method (see <a href="http://www.untoldentertainment.com/blog/2010/11/22/understanding-arrays/">Understanding Arrays</a> for more info).</p>
<h2>You Get a-NOTHING!!!</h2>
<p>What do we do about a Function that doesn&#8217;t return any value at all?  Can we just leave that little section at the end of the declaration blank?   Well, you <em>can</em>, but it all depends on how picky your compiler is.  You can set the Flash compiler to <b>Strict</b> mode &#8230; certain other compilers are strict by default.  This means that every variable must be typed (given a datatype), and every Function must also be typed.</p>
<p>The keyword for &#8220;no type&#8221; is <b>void</b>.  If your Function doesn&#8217;t return a value, type it as void:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> thisReturnsNothing<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h2>Return Stops the Show</h2>
<p>The only really important thing to know about the <b>return</b> keyword is that when the code interpreter chews its way down to that line, it&#8217;s like hitting the EJECT button.  The interpreter gets booted out of your Function, regardless of whatever statements you may have written beneath it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #66cc66;">&#40;</span>playerName : <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;Hello, &quot;</span> + playerName;
    <span style="color: #808080; font-style: italic;">// This line doesn't get executed.</span>
    <span style="color: #808080; font-style: italic;">// Neither does this one.</span>
    <span style="color: #808080; font-style: italic;">// Nor this one.</span>
    <span style="color: #808080; font-style: italic;">// In fact, anything you write after a return statement gets skipped.</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h2>Breaking Stuff</h2>
<p>As with arguments, there are some great ways to break a Function with return values. In brief, here&#8217;s how to do it:</p>
<ol>
<li>Return a value even though your Function is typed <b>void</b> (or it&#8217;s untyped).
<li>Type your Function to return a value, and don&#8217;t return a value.
<li>Return a datatype that&#8217;s different than the return type declaration.
<li>Write some branching logic so that it&#8217;s possible your Function may not return a value.
</ol>
<p>Let&#8217;s look at each of these, and the error statements that pop up when we make each mistake.</p>
<h2>1. Return a Value When You Shouldn&#8217;t</h2>
<p>Here&#8217;s an example of a Function that is typed <b>void</b>, but it returns an int:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> whoops<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">57</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>When you do this, here&#8217;s the error that the Flash compiler throws:</p>
<blockquote><p>
Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 3	1051: Return value must be undefined.</p></blockquote>
<p>That&#8217;s a pretty clear error message.  Thank you, eggheads.</p>
<p>Here&#8217;s the error message you get when you use Unity javascript:</p>
<blockquote><p>Assets/NewBehaviourScript.js(3,12): BCE0022: Cannot convert &#8216;int&#8217; to &#8216;void&#8217;.</p></blockquote>
<p>Again, with a tiny bit of detective work, this error is not too tricky to sort out.  The compiler thinks you&#8217;re trying to make it force a value of type int to be a value of type void (which is what you&#8217;re returning), but this is impossible, <em>even for computers</em>.</p>
<h2>2. Promise a Return Value, and then Cop Out</h2>
<p>If we type a Function with anything other than <b>void</b>, we&#8217;re pledging to return a value.  If we don&#8217;t return a value of that type, the compiler shows up on our doorstep in the middle of the night with mascara streaking her cheeks, demanding to know why you never do the things you say you&#8217;re going to do.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/psychogf.jpg" alt="Psycho Girlfriend"></p>
<p>You said we would have BABIES!  And ints!!!
</p></div>
<p>Here&#8217;s an example of a promise a programmer didn&#8217;t follow up on with a return statement:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> makeBabiesWithTanya<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">int</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> numberOfBabiesWeCanHave : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">17</span>;
    <span style="color: #808080; font-style: italic;">// Honest.</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So because the <b>return</b> statement is missing, this Function doesn&#8217;t actually give Tanya any babies.  And that&#8217;s when she notices something is up:</p>
<blockquote><p>Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 5	1170: Function does not return a value.</p></blockquote>
<p>This is one of the clearest error messages you&#8217;ll ever receive when using Actionscript 3.  Let&#8217;s see how it looks in Unity javascript:</p>
<blockquote><p>(no error)</p></blockquote>
<p>Unity is clearly a lot more easy-going about this type of thing.  Remember that when you&#8217;re thinking of which one you should invite on a road trip to Vegas.</p>
<h2>3. Return the Wrong Datatype</h2>
<p>If the Function is typed <b>int</b>, we gotta return an int.  If it&#8217;s typed <b>Array</b>, we gotta return an array.  Here&#8217;s an obvious boob:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> iAmConfused<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">int</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;nyearrrghhh&quot;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This Function is typed <b>int</b>, but we&#8217;re returning a String.  Here&#8217;s the Flash error:</p>
<blockquote><p>Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 3	1067: Implicit coercion of a value of type String to an unrelated type int.</p></blockquote>
<p>Nice and clear.  And in Unity javascript:</p>
<blockquote><p>Assets/NewBehaviourScript.js(3,12): BCE0022: Cannot convert &#8216;String&#8217; to &#8216;int&#8217;.</p></blockquote>
<p>These are both very similar, and they do a pretty good job at getting the point across.</p>
<h2>4. Faulty Logic</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/labyrinth.jpg" alt="The Labyrinth">
</div>
<p>If you write a Function that should return a value, and you load it up with branching conditional logic, the compiler will actually step through that logic to make sure a value gets returned.  Here&#8217;s an example of a logic structure that may never return the value promised by the Function:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> badLogic<span style="color: #66cc66;">&#40;</span>playerName : <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
     <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>playerName == <span style="color: #ff0000;">&quot;Pete&quot;</span><span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#123;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;Hi, Pete!&quot;</span>;
     <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>playerName == <span style="color: #ff0000;">&quot;Carl&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;Hi, Carl!&quot;</span>;
     <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So if the playerName is Pete, we return &#8220;Hi, Pete&#8221;, and if the playerName is Carl, we return &#8220;Hi, Carl&#8221;.  But what if the playerName is Suzie, Jasmine, Turk, Paolo or Ferdinand?  In that case, neither of the statements will get executed, and so it&#8217;s possible that the Function will not return a value.</p>
<p>Here&#8217;s what the Actionscript 3 compiler has to say about that:</p>
<blockquote><p>Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 9	1170: Function does not return a value.</p></blockquote>
<p>Clear as crystal!  And now, Unity javascript:</p>
<blockquote><p>(no error)</p></blockquote>
<p>Hmm.  Now we&#8217;re up against a situation where permissive coding isn&#8217;t always a good thing.  As a very new programmer, you might think &#8220;the fewer errors, the better&#8221;.  But if you&#8217;re expecting that Function to return a value, and it somehow doesn&#8217;t, wouldn&#8217;t it be <em>more</em> helpful to see an error telling you what went wrong?</p>
<p>Answer: yes.  Yes it would.</p>
<h2>Your Triumphant Return</h2>
<p>Those are the essentials of writing Functions that return values.  Together with <a href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/">Understanding Functions</a> and <a href="http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/">Understanding Functions &#8211; Arguments</a>, you should have a complete picture of what Functions are and what they can do.  But this is the HOW, not then WHEN of it.  These articles just discuss the <em>building blocks</em> of Object-Oriented Programming.  Assembly instructions, and even freestyle building &#8211; are entirely different matters altogether.</p>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature. </p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F03%2Funderstanding-functions-return-values%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F03%2Funderstanding-functions-return-values%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/03/understanding-functions-return-values/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3259&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/03/understanding-functions-return-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Functions &#8211; Arguments</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 05:49:09 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3246</guid>
		<description><![CDATA[There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Functions are one of them. In Understanding Functions, we learned that Functions are a way to bundle code statements together into a tight little unit that we can invoke (or &#8220;call&#8221;) any time [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Functions are one of them.</p>
<p>In Understanding Functions, we learned that Functions are a way to bundle code statements together into a tight little unit that we can invoke (or &#8220;call&#8221;) any time we like, and as often as we like.  There are two very important features to learn about Functions: Arguments and Return Values.  We&#8217;ll figure out Arguments in this article.</p>
<h2>Til You&#8217;re Blue in the Face</h2>
<p>Arguments aren&#8217;t as unfriendly as they sound.  They&#8217;re just additional pieces of information we can send to a Function during a Function call.  You&#8217;ll remember that a Function call looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Quite often, we need to pass additional information to Functions to make them super-useful.  Let&#8217;s imagine we have a text input field where the player can enter his name.  The player types in his name and clicks a button, and the game says &#8220;Hello, John&#8221; (or whatever the player&#8217;s name is).  The <em>dynamic</em>, or changing, part of that Function is the player&#8217;s name.  Here&#8217;s how that Function might look if it was &#8220;hard-coded&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello, John.&quot;</span><span style="color: #66cc66;">&#41;</span>;  <span style="color: #808080; font-style: italic;">// ain't nothing dynamic about this</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>Note:</b> Unity javascript people will want to start the function name with a capital letter as a best practice, and use either <b>print</b> or <b>Debug.Log</b> in place of trace.</p>
<p>This is okay, but the problem is that every time we <b>call</b> (run, execute, do) that Function, it&#8217;s going to say &#8220;Hello, John.&#8221;  What if the player&#8217;s name isn&#8217;t John?  Well, we need to make that part dynamic, because it changes.</p>
<h2>Dynamic!</h2>
<p>Let&#8217;s set up our Function so that we say &#8220;Hello&#8221;, and then tack on a variable that holds the player&#8217;s name:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello, &quot;</span> + playerName<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>(When working with Strings, the <b>+</b> operator glues two strings together.)</p>
<p>It&#8217;s getting better, but we have a new problem: the code interpreter is going to see playerName and think &#8220;playerName?  What the heck is that?&#8221;  Then it&#8217;s going to freak out and the Earth is going to crash into the Sun, and we don&#8217;t want that.</p>
<p>We need to declare and define the playerName variable somewhere.  But instead of just declaring playerName any old place, we&#8217;re going to <em>tell</em> the sayHello Function which playerName we&#8217;d like it to say.  We&#8217;re going to set our sayHello Function up so that it has a <b>parameter</b>.  We do that between the round brackets in the Function declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #66cc66;">&#40;</span>playerName : <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello, &quot;</span> + playerName<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>Parameters</b> go between the round brackets in a Function declaration. In the continuing tradition of seeing our blocks of code as visual elements, check this out:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/artistVision.jpg" alt="Parameters"></p>
<p>If you&#8217;re a visual person, learning to see code in blocks like this could help you out a lot.
</p></div>
<p>When we structure a Function this way, we say that the sayHello Function <em>accepts</em> one parameter, which is called playerName.  The <b>type</b> of playerName is a String (a list of letters and/or numbers). Notice that even though this is kind of like a variable declaration, we don&#8217;t need to use the <b>var</b> keyword.</p>
<h2>Exact Change Required</h2>
<p>i like to think of <b>parameters</b> as the <em>payment</em> that a Function accepts. The sayHello Function takes one <b>argument</b> and stores it in its first <b>parameter</b>. Since the first parameter is of type <b>string</b>, we need to &#8220;pay&#8221; it a string.  If we pay any other datatype (int, float, number, boolean, array), the compiler will throw an error. </p>
<p>Here&#8217;s how we &#8220;pay&#8221; a string to the sayHello Function:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Murphy&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Freeze frame!  Let&#8217;s become the Pac Man-like code interpreter and follow the logic of this statement for a moment.</p>
<p>The interpreter gets to this line and recognizes it as a Function call, thanks to those round brackets at the end.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step1.jpg" alt="Step 1"></p>
</div>
<p>It also sees &#8211; hey! &#8211; the programmer has passed an argument to the Function inside those round brackets.  So Pac Man puts that in his suitcase, hops in the DeLorean, and travels off in search of the sayHello Function.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step2.jpg" alt="Step 2"></p>
</div>
<p>When he finds it, before he starts chewing through the statements in the statement block (between the curly braces), the Pac Man-like code interpreter drops off the argument into the waiting playerName parameter bucket, between the round brackets of the Function declaration.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step3.jpg" alt="Step 3"></p>
</div>
<p>Now the parameter called playerName has a value of &#8220;Murphy&#8221;.  Since &#8220;Murphy&#8221; is a String, and since the sayHello Function demands exact change (one argument of type <b>String</b>), we&#8217;re good to go!</p>
<p>With payment resolved, the code interpreter chews through the statements in the statement block (between the curly braces), reaches the bottom of the Function, and hops back in the DeLorean to pick up where he left off, back at the end of the Function call.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_02/step4.jpg" alt="Step 4"></p>
</div>
<p>Because the value of the variable playerName is the String &#8220;Murphy&#8221;, the result is that the console/output window says <b>Hello, Murphy</b>.  It will say Hello to whatever name we pass in as an argument.</p>
<h2>Breakamage Pt.1 &#8211; Wrong Datatype</h2>
<p>It&#8217;s really important to break code and cause errors, so that when you&#8217;re in a jam on a project and an error comes up, you&#8217;ll know what it means and how to deal with it.</p>
<p>Try tweaking the sayHello Function call so that you pass an int (integer/whole number) instead of a String:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">42</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>42 is not a String.  Your first clue is that it&#8217;s missing those double-quotation marks around it.  Since the sayHello Function <em>DEMANDS</em> exactly one string as payment, the compiler throws an error.</p>
<p>This is what that error looks like when we use ActionScript 3:</p>
<blockquote><p>Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 1	1067: Implicit coercion of a value of type int to an unrelated type String.</p></blockquote>
<p>i really take exception to the way eggheads write error messages.  They could stand to be a LOT more clearly written.  But here&#8217;s what this error is trying to say:  &#8220;implicit coercion&#8221; means you&#8217;re trying to force something to be something else, and ActionScript 3 can&#8217;t manage it.  In this case, you&#8217;re trying to force an int (42) to become a String when Pac Man delivers the goods to the sayHello Function, and the compiler is having a minor freak-out.  That&#8217;s your clue that you may have passed a mismatched type as an argument to a Function.</p>
<p>This is the error message that the same mistake will cause in Unity javascript;</p>
<blockquote><p>Assets/NewBehaviourScript.js(4,10): BCE0017: The best overload for the method &#8216;Tutorial.sayHello(String)&#8217; is not compatible with the argument list &#8216;(int)&#8217;.</p></blockquote>
<p>Ugh!  You eggheads are <em>killing me</em>.  Forget what an &#8220;overload&#8221; is and focus in on the part that (sorta) makes sense to you right now: <em>something</em> is not compatible with the argument list.  You can see quite clearly that one is a String, and the other is an int.  That&#8217;s your clue that you&#8217;ve botched the argument type.  Go back and patch this up, and you&#8217;ll be golden.</p>
<h2>Extremely Argumentative</h2>
<p>So is that it?  Can Functions only accept one argument?  No &#8230; they can actually accept multiple arguments.  Be sure to comma-separate them, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">makePizza<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;pepperoni&quot;</span>, <span style="color: #ff0000;">&quot;mustard&quot;</span>, <span style="color: #ff0000;">&quot;tree bark&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> makePizze<span style="color: #66cc66;">&#40;</span>topping1 : <span style="color: #0066CC;">String</span>, topping2 : <span style="color: #0066CC;">String</span>, topping3 : <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>B..but &#8230; do they all have to be the same datatype (String)?   Heck no!  You can mix and match.  The only rules are that you need to pass the arguments into the Function in the same order as the parameter list, and you need to pass the same <em>number</em> of arguments the Function requires.  The Pac Man-like code interpreter unpacks these one at a time in order.  So let&#8217;s pretend there&#8217;s a function that takes a String, an int and an Array (in that order):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> initPatient<span style="color: #66cc66;">&#40;</span>patientName : <span style="color: #0066CC;">String</span>, age : <span style="color: #0066CC;">int</span>, aPhobias : <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As long as we pass in a String, an int and an Array, in that order, it works:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> theName : <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Shaggy&quot;</span>;
<span style="color: #000000; font-weight: bold;">var</span> theAge : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">17</span>;
<span style="color: #000000; font-weight: bold;">var</span> aThePhobias : <span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;like, ghosts&quot;</span>, <span style="color: #ff0000;">&quot;like, zombies&quot;</span>, <span style="color: #ff0000;">&quot;like, creepy-crawly things&quot;</span><span style="color: #66cc66;">&#41;</span>;
initPatient<span style="color: #66cc66;">&#40;</span>theName, theAge, aThePhobias<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>That&#8217;s fine.  But as soon as we mix up the order, there&#8217;s trouble:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> theName : <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Shaggy&quot;</span>;
<span style="color: #000000; font-weight: bold;">var</span> theAge : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">17</span>;
<span style="color: #000000; font-weight: bold;">var</span> aThePhobias : <span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;like, ghosts&quot;</span>, <span style="color: #ff0000;">&quot;like, zombies&quot;</span>, <span style="color: #ff0000;">&quot;like, creepy-crawly things&quot;</span><span style="color: #66cc66;">&#41;</span>;
initPatient<span style="color: #66cc66;">&#40;</span>theAge, theName, aThePhobias<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// ERROR!  Totally long-winded explanation that could really be made a lot more clear, but eggheads aren't about making other people's lives easier (unfortunately).  In short, argument type mismatch.</span></pre></div></div>

<p>So far so good?  You may have noticed that i made the names of the variables i passed into the Function as arguments conspicuously different than the names of the parameters i accepted in the initPatient Function.  This is because i wanted you to see that there is a difference between these two things, and that there CAN be a difference.  When you call a Function and pass it some arguments, the variable names you pass in don&#8217;t matter &#8230; it&#8217;s the values <em>stored</em> in those variables that Pac Man takes with him on his journey.</p>
<h2>Breakamage Pt.2 &#8211; Wrong Number of Arguments</h2>
<p>Just as sending in the wrong <em>type</em> of argument will throw an error (ie paying a quarter when the Function wants a nickel), the compiler will throw an error if you pass in the wrong <em>number</em> of arguments.</p>
<p>In this example, we have a Function that accepts one argument, but we try to pass it two arguments:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> eatBacon<span style="color: #66cc66;">&#40;</span>numberOfStrips : <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;OM NOM NOM!  I just ate &quot;</span> + numberOfStrips + <span style="color: #ff0000;">&quot; strips of delicious bacon.&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
eatBacon<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">57</span>, <span style="color: #ff0000;">&quot;i can haz heart attack&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// ERROR!!</span></pre></div></div>

<p>The function wants only one argument, but we&#8217;re sending it two. Here&#8217;s what the error looks like when we use Actionscript 3:</p>
<blockquote><p>Scene 1, Layer &#8216;Layer 1&#8242;, Frame 1, Line 6	1137: Incorrect number of arguments.  Expected no more than 1.</p></blockquote>
<p>Thankfully, this is one of the clearest error message i&#8217;ve ever seen an egghead write.</p>
<p>This is what the error looks like when we use Unity javascript (changing <b>trace</b> to either <b>print</b> or <b>Debug.Log</b> and using a capital letter to begin our Function name):</p>
<blockquote><p>Assets/NewBehaviourScript.js(8,9): BCE0017: The best overload for the method &#8216;NewBehaviourScript.eatBacon(int)&#8217; is not compatible with the argument list &#8216;(int, String)&#8217;.</p></blockquote>
<p>That&#8217;s the same error we get when there&#8217;s an argument type mismatch, so the Actionscript eggheads did a slightly better job of communicating the problem than the Unity eggheads did.  The important thing is that you learn to recognize why Unity or Flash are throwing the error so that you can fix it quickly and get on with your project.</p>
<p>Note that you&#8217;ll throw an error even if you &#8220;overpay&#8221; a Function.  If a Function wants exactly two arguments, and you give it nine, you&#8217;ll get one of these errors. </p>
<h2>But Wait &#8211; There&#8217;s More!</h2>
<p>There are two more advanced topics when it comes to passing and accepting arguments &#8211; optional arguments, and Rest arguments.  They&#8217;re useful, but not crucial.  We&#8217;ll be sure to cover them in future articles.</p>
<p>For now, get some practice passing arguments to your Functions, and writing parameters to store those articles.  <em>The fate of the free world may depend on it!</em>  Or whatever.</p>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature. </p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F02%2Funderstanding-functions-arguments%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F02%2Funderstanding-functions-arguments%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3246&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/02/understanding-functions-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Functions</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 17:02:46 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3 Helper Class]]></category>
		<category><![CDATA[Bizarre]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3243</guid>
		<description><![CDATA[There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Functions are one of them. Bang on De Drum All Day Here&#8217;s a secret about programmers: they are inherently lazy. The less typing a programmer can do, the better. Programming is all about [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages.  Functions are one of them.</p>
<h2>Bang on De Drum All Day</h2>
<p>Here&#8217;s a secret about programmers: they are inherently lazy.  The less typing a programmer can do, the better.  Programming is all about dreaming up complex tasks that programmers don&#8217;t want to do, and delegating those tasks to a computer so that the programmer can blow off and watch cartoons the rest of the day.</p>
<p>Many programming structures are designed to make a programmer&#8217;s life easier.  And a programming rule of thumb is <em>generally</em> that if you have to type something twice, there&#8217;s an opportunity to make your code more efficient.</p>
<p>Functions make your code more efficient.  Let&#8217;s imagine a game where we need to create a bunch of monsters.  If you&#8217;ve read <a href="http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/">Understanding Loops</a>, you know that you can set up a loop to run an action multiple times.  i&#8217;ll use a combination of pseudocode (in comments) and real code to demonstrate:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make 50 monsters.</span>
<span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// make a monster</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So far so good.  But there are a few other things we have to do with these monsters we create.  We need to put each one on a hill.  Then we need to dress each monster up in a Power Hat.  Next, we need to hide a key to each monster&#8217;s hilly domain.  Let&#8217;s modify the loop:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make 50 monsters.</span>
<span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// make a monster</span>
    <span style="color: #808080; font-style: italic;">// put the monster on a hill</span>
    <span style="color: #808080; font-style: italic;">// put a power hat on the monster</span>
    <span style="color: #808080; font-style: italic;">// hide a key</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Mmmm &#8230; we&#8217;re almost there.  Now we need to create a portrait for that each monster and put it inside the castle, so that when the hero defeats a monster, the portrait gets a big checkmark on it.  Then we need to create a magic gem that will kill each monster.  Each gem needs to be buried somewhere underground.  Finally, we need to create a villager for each monster in the game. Each villager will give you a clue as to where to find the monster-killing gem.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make 50 monsters.</span>
<span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// make a monster</span>
    <span style="color: #808080; font-style: italic;">// put the monster on a hill</span>
    <span style="color: #808080; font-style: italic;">// put a power hat on the monster</span>
    <span style="color: #808080; font-style: italic;">// hide a key</span>
    <span style="color: #808080; font-style: italic;">// create a portrait</span>
    <span style="color: #808080; font-style: italic;">// put the monster's face on the portrait</span>
    <span style="color: #808080; font-style: italic;">// put the portrait inside the castle</span>
    <span style="color: #808080; font-style: italic;">// create a gem</span>
    <span style="color: #808080; font-style: italic;">// bury the gem underground</span>
    <span style="color: #808080; font-style: italic;">// create a villager</span>
    <span style="color: #808080; font-style: italic;">// give the villager a gem clue</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Oh man.  This loop is getting real ugly, real fast.  There&#8217;s so much STUFF in there.  It&#8217;s getting out of control.</p>
<p>If we take a close look, we see that we&#8217;re running a few tasks that can be grouped together.  All the monster stuff goes together.  All the key stuff goes together.  The gem stuff goes together.  The villager stuff goes together.  That&#8217;s four separate <em>bundles</em> of tasks that, like a pile of sticks, we should be able to wrap up with twine in a tidy little package.</p>
<h2>I Have a Tiny Little Package</h2>
<p>That&#8217;s one of the things Functions do for us:  they allow us to group related tasks together into a little package, and we can refer to that package over and over again without having to repeat any lines.</p>
<p>A <b>Function declaration</b> looks very much like a variable or array declaration.  Instead of the <b>var</b> keyword, we use the <b>function</b> keyword.  In ECMA-based languages like Actionscript 3, Unity javascript and C#, functions are followed by round brackets.  Then you open up a statement block between curly brackets, just like in a <b>For Loop</b> or a conditional (If) statement:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">// statements go here</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>Note:</b> If you&#8217;re using Unity javascript, best practice is to begin a function name with a capital letter.</p>
<p>So <b>doSomething</b> is our function name.  That&#8217;s a custom name that we came up with.  It makes a lot of sense to use verbs (action words) when naming your functions.  We&#8217;ll see why in a moment.</p>
<p>Let&#8217;s carve out the statements involving the monsters and put them in their own function:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> initMonsters<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// make a monster</span>
    <span style="color: #808080; font-style: italic;">// put the monster on a hill</span>
    <span style="color: #808080; font-style: italic;">// put a power hat on the monster</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>(the &#8220;init&#8221; here is short for &#8220;initialize&#8221;, which means &#8220;set it up&#8221;)</p>
<p>Now, back in the loop, we can substitute those three statements with a <b>Function call</b>.  A Function call always uses the name of the function, followed by round brackets, with a semi-colon to end the statement.  Take a look:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make 50 monsters.</span>
<span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    initMonsters<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// We removed these three statements and put them in their own function.</span>
    <span style="color: #808080; font-style: italic;">// Now, we just call the function.</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">// hide a key</span>
    <span style="color: #808080; font-style: italic;">// create a portrait</span>
    <span style="color: #808080; font-style: italic;">// put the monster's face on the portrait</span>
    <span style="color: #808080; font-style: italic;">// put the portrait inside the castle</span>
    <span style="color: #808080; font-style: italic;">// create a gem</span>
    <span style="color: #808080; font-style: italic;">// bury the gem underground</span>
    <span style="color: #808080; font-style: italic;">// create a villager</span>
    <span style="color: #808080; font-style: italic;">// give the villager a gem clue</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>In common programming parlance, this is called <em>calling a Function</em>.</p>
<p>To understand how a function call works, we need to put ourselves back in the role of our code interpreter, which is a lot like Pac Man.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_01/functions.jpg" alt="Pac Man and functions"></p>
</div>
<p>Pac Man hits the first statement in the loop.  It&#8217;s a function call.  So he jumps out of the loop to wherever the Function is declared, and chews through all of the statements in that Function. When he reaches the bottom of the Function, he bounces back to the loop again, and resumes chewing through code at the very next line.</p>
<p>This works very nicely.  Now we can go through and offload all of our chunks of functionality into their own Functions.  When we write it all up, i looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make 50 monsters.</span>
<span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    initMonsters<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    initKeys<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    initPortraits<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    initGems<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    initVillagers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Look how much easier to read that loop is now. It&#8217;s very clear that we loop 50 times, and each time we make some monsters, some keys, some portraits, some gems, and some villagers.  The details for each process are buried in their respective functions.  Now, when we look at the initKeys function, we only have to worry about tasks related to initializing those keys.</p>
<p>This bouncing around that the Pac Man-like code interpreter does is the reason why i say that Object Oriented Programming (OOP) is like taking multiple plane flights through time portals. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/map.jpg" alt="Pac Man Map"></p>
<p>Pac to the Future
</p></div>
<p>There are two more very important things to learn about functions: Arguments and Return Values.  These are detailed in two additional articles.  Once you read through those, you&#8217;ll know almost everything there is to know about Functions, and you&#8217;ll be ready to start putting that knowledge into practice by building your own stuff!</p>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature.
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F01%2Funderstanding-functions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F01%2Funderstanding-functions%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3243&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/01/understanding-functions/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Understanding Loops with Arrays</title>
		<link>http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 16:02:00 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3224</guid>
		<description><![CDATA[There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Arrays are one of them. Loops are another. i covered both of these structures in the previous aptly-named articles Understanding Arrays and Understanding Loops. Now that we understand loops, and we understand arrays, [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages.  Arrays are one of them.  Loops are another.  i covered both of these structures in the previous aptly-named articles <a href="http://www.untoldentertainment.com/blog/2010/11/22/understanding-arrays/">Understanding Arrays</a> and <a href="http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/">Understanding Loops</a>.</p>
<p>Now that we understand loops, and we understand arrays, we&#8217;re ready to smack their featureless plastic genitals together like we&#8217;re making Barbie have babies. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_01/wonderTwins.gif" alt="Wonder Twins"></p>
<p>(Which one of these is the chick again?)
</p></div>
<p>Arrays really come alive with Loops.  By using an Array&#8217;s <b>length</b> property as the loop limiter, we can step through every element in an Array one by one.</p>
<p>Here&#8217;s what that looks like in code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> myArray:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Nigel Tufnel&quot;</span>, <span style="color: #ff0000;">&quot;Derek Smalls&quot;</span>, <span style="color: #ff0000;">&quot;David St. Hubbins&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> =<span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>myArray.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>myArray<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// This prints each element in the array, one by one, to the console/output window </span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>Note:</b> If you&#8217;re using Unity javascript, try print or Debug.Log instead of trace.</p>
<p>If you truly understand Loops, this shouldn&#8217;t be too challenging for you.  Instead of using some arbitrary value like one thousand as our limiter, we&#8217;re using the array&#8217;s <b>length</b> property, which is the number of elements in the array.  This property is dynamic, so that any time we add things to our array, or take them away, length is updated for us. We don&#8217;t have to rely on a hard-coded value (which means a number that doesn&#8217;t change).</p>
<p>The code snippet shown above traces out each element in the array, one after the other:</p>
<ul>
<li>Nigel Tufnel
<li>Derek Smalls
<li>David St. Hubbins
</ul>
<p>This is because on every <b>iteration</b> of the loop, our <b>iterator</b> variable called <b>i</b> is increased by one.</p>
<p><b>i</b> begins life with a value of 0.  On the first run through the loop, the code interpreter <b>resolves</b> myArray[i] to myArray[0].  The first element in the array, at index 0, is &#8220;Nigel Tufnel&#8221;, so that&#8217;s what you&#8217;ll see in the output console.</p>
<p>On the next iteration, <b>i</b> gets jacked up to 1.  The element at index 1 in the array is &#8220;Derek Smalls&#8221;, so that&#8217;s what prints out.  </p>
<p>Finally, in the third and final round, we print out &#8220;David St. Hubbins&#8221;, because myArray[i] resolves to myArray[2].  The element at index 2 of the array is &#8220;David St. Hubbins&#8221;.</p>
<p>After that, the interpreter bounces back to the top of the loop.  i is incremented to 3.  We check the limiter: </p>
<p><b>i < myArray.length</b></p>
<p>Because <b>i</b> is 3 and myArray.length is also 3, this line resolves to 3 < 3.  Since 3 is not less than 3, the answer here is <b>false</b>.  And because the answer is false, the code interpreter is not allowed to go through the loop any more.  It happily exits the loop and starts chewing through the code beneath the bottom closed curly brace that ties up the loop.</p>
<p><b>Protip:</b> If you&#8217;re a stickler for speed, it&#8217;s marginally faster to store myArray.length in a variable, to prevent your interpreter from having to do the length calculation on every iteration of your loop. Here&#8217;s what that looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> myArray:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Nigel Tufnel&quot;</span>, <span style="color: #ff0000;">&quot;Derek Smalls&quot;</span>, <span style="color: #ff0000;">&quot;David St. Hubbins&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> =<span style="color: #cc66cc;">0</span>;
<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span> = myArray.<span style="color: #0066CC;">length</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>myArray<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>We store myArray.length in a variable called len, and then refer to that variable in the limiter section of the loop header.</p>
<p>For even <em>more</em> of a tiny speed increase, do away with the <b>new</b> keyword and declare the array like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> myArray:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Nigel Tufnel&quot;</span>, <span style="color: #ff0000;">&quot;Derek Smalls&quot;</span>, <span style="color: #ff0000;">&quot;David St. Hubbins&quot;</span><span style="color: #66cc66;">&#93;</span>;</pre></div></div>

<h2>Who Cares?</h2>
<p>This is all still pretty pointless.  When are you ever going to use this when programming a game?  Well, for the rest of the article, i&#8217;ll lay some real-world examples on you to give you an idea of how to maximize the wonderful union of Loops with Arrays.</p>
<p>Think of any situation in a video game when you have a list of similar things.  In a first person shooter, you need to keep track of all the bullets that get fired.  Makes sense to create an array to store all of those bullets.  You can add bullets to the list and remove them from the list using the Array class methods we looked at in the Understanding Arrays article.</p>
<p>Most games run on one giant loop, with an Update process and a Draw process.  <b>Update</b> figures out where everything should be, and <b>Draw</b> renders those things to the player&#8217;s view.  If you want to update the positions of all the bullets, you may need to use a <b>For Loop</b> to loop through your collection of bullets and move them one tiny bit.  Then in the Draw process, you loop through your list of bullets and render them to the screen. When you repeat these processes quickly enough, you get the illusion of animation.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_01/blackOps.jpg" alt="Black Ops"></p>
<p>We might keep separate lists of the bullets, the enemies, the friendlies, and the bomb shells.
</p></div>
<p>Very often, you&#8217;ll use a loop to create the initial array of objects, and then more loops later to pick through that list.  Here&#8217;s an example of two functions.  One initializes all of the monsters, and the other kills all of the monsters (assuming the player just used the &#8220;Kill All Monsters&#8221; megabomb power-up).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> aMonsters:<span style="color: #0066CC;">Array</span>; <span style="color: #808080; font-style: italic;">// this array is a bucket that can hold many things: namely, monsters.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> initMonsters<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
     aMonsters = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;  <span style="color: #808080; font-style: italic;">// Defines an empty instance of the Array class.</span>
     <span style="color: #000000; font-weight: bold;">var</span> totalMonsters:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">50</span>; <span style="color: #808080; font-style: italic;">// this is a variable (bucket) that contains the number of monsters we'd like to begin with</span>
     <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalMonsters; i++<span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#123;</span>
         aMonsters.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Monster<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Creates a new instance of the Monster class, and adds that instance to the aMonsters array.  </span>
         <span style="color: #808080; font-style: italic;">// If that's confusing to you, we can split this up into two separate lines:</span>
         <span style="color: #808080; font-style: italic;">// var monster:Monster = new Monster();</span>
         <span style="color: #808080; font-style: italic;">// aMonsters.push(monster);</span>
     <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> killAllMonsters<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span> = aMonsters.<span style="color: #0066CC;">length</span>; <span style="color: #808080; font-style: italic;">// store the length of the aMonsters array in a variable called len.</span>
     <span style="color: #808080; font-style: italic;">// By doing this, we speed up our loop ever so slightly.</span>
     <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">var</span> monster:Monster = aMonsters<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// stores a reference to the first monster in the array</span>
         monster.<span style="color: #006600;">die</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// calls some sort of death method on the monster instance</span>
         aMonsters.<span style="color: #006600;">shift</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// removes the first element of the array.  The aMonsters array gets shorter and shorter every time we loop, as we remove monster after monster.  By the end of this loop, the aMonsters array is empty.</span>
     <span style="color: #66cc66;">&#125;</span>   
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>Note:</b> If some of the initialization stuff here looks a bit spooky, try reading the <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Understanding Classes</a> series.  Hopefully you&#8217;re catching what i&#8217;m throwing regarding loops and arrays, even if the class stuff is a little unfamiliar.</p>
<p><b>For Unity javascript:</b> Everything here is almost identical &#8230; the main difference is that methods like <b>push</b> begin with capital letters.</p>
<p>Those double-slashes, by the way, are <b>comments</b>.  They are ignored by the compiler, and are added to clarify the code.</p>
<h2>Get Carded</h2>
<p>Here&#8217;s another example.  Let&#8217;s say we&#8217;re programming a card game.  We can use an array to store our deck of cards.  Each element in the array is a card.  We use one loop to build the deck.  Then we shuffle the deck.  Finally, we use a loop to deal some cards onto the table, using the Array.shift() method to deal off the top of the deck.  This removes the cards from the array one by one, and adds them to a different array called aCardsOnTable.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> aDeck:<span style="color: #0066CC;">Array</span>; <span style="color: #808080; font-style: italic;">// declare an array to hold all the cards</span>
<span style="color: #000000; font-weight: bold;">var</span> aCardsOnTable:<span style="color: #0066CC;">Array</span>; <span style="color: #808080; font-style: italic;">// declare an array to hold the cards that we deal out</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> buildDeck<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    aDeck = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// create an empty instance of the Array class and store it in a variable called aDeck</span>
    <span style="color: #000000; font-weight: bold;">var</span> totalCards:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">52</span>; <span style="color: #808080; font-style: italic;">// we want 52 cards in the deck, so that's how many times we'll loop</span>
    <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>totalCards; i++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
         aDeck.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Card<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// we instantiate the Card class, and add the new card instance to the aDeck array.</span>
         <span style="color: #808080; font-style: italic;">// Once again, if we're doing too much in this line for you to follow along, here's a longer version of the same code in two steps:</span>
        <span style="color: #808080; font-style: italic;">// var card:Card = new Card(); // create the card instance and store it in a variable</span>
        <span style="color: #808080; font-style: italic;">// aDeck.push(card); // add the card instance to the aDeck array</span>
    <span style="color: #66cc66;">&#125;</span>
    shuffle<span style="color: #66cc66;">&#40;</span>aDeck<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// this is a custom function that you'll probably have to write yourself (just like the Card class).  It randomizes all of the elements in the array.</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> dealCards<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    aCardsOnTable = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// define aCardsOnTable as an empty array</span>
    <span style="color: #000000; font-weight: bold;">var</span> numCardsToDeal : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">5</span>; <span style="color: #808080; font-style: italic;">// Let's deal 5 cards to the table.</span>
    <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>numCardsToDeal; i++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
         aCardsOnTable.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>aDeck.<span style="color: #006600;">shift</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// pulls the first element out of aDeck, and adds it to aCardsOnTable</span>
         <span style="color: #808080; font-style: italic;">// That's a bit of shorthand.  Let me blow that line out into separate steps in case you're having trouble following it:</span>
         <span style="color: #808080; font-style: italic;">// var topCard:Card = aDeck.shift();  // use shift to pull out the first card in the aDeck array, and store it in a variable called topCard</span>
         <span style="color: #808080; font-style: italic;">// aCardsOnTable.push(topCard); // add the card we removed to the end of the aCardsOnTable array.</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #808080; font-style: italic;">// When we finish with this loop, there are 5 cards in the aCardsOnTable array,</span>
    <span style="color: #808080; font-style: italic;">// and 47 cards left in the aDeck array.</span>
    <span style="color: #808080; font-style: italic;">// This is a great way to deal out cards!   By removing a card from the aDeck array each time using shift(), we ensure that we'll never deal the same card twice.</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Those previous two examples are very similar. Here&#8217;s another real-world example that&#8217;s slightly different.</p>
<h2>Looping Through Movieclips on the Stage</h2>
<p>Super eggheads like to lay out their GUIs (graphical user interfaces &#8211; buttons and windows and text boxes and junk) entirely in code.  i don&#8217;t prefer to do it that way, because i&#8217;m a very visual person, and i like to <em>see</em> my interface laid out on-screen.  i like to be able to poke, prod and nudge things around visually.</p>
<p>So often, i&#8217;ll have a bunch of buttons on the stage.  The buttons all have instance names.  i&#8217;ll put those instance names in an array, and then loop through the array to add standard buttonMode, rollover and rollout effects to all the buttons in one shot.  Here&#8217;s how that looks, presuming i have the buttons &#8220;phyiscally&#8221; on my stage and named properly:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">// i call the initBtns function somewhere in my code</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> initBtns<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> aBtnNames:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;btnPlay&quot;</span>, <span style="color: #ff0000;">&quot;btnQuit&quot;</span>, <span style="color: #ff0000;">&quot;btnCredits&quot;</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// we store the instance names of my on-stage buttons in an array</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span> = aBtnNames.<span style="color: #0066CC;">length</span>; <span style="color: #808080; font-style: italic;">// Let's dynamically loop through as many buttons as we have in the array.</span>
    <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
         activateBtn<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span>aBtnNames<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
         <span style="color: #808080; font-style: italic;">// Here's a slower, possibly clearer way to say that:</span>
         <span style="color: #808080; font-style: italic;">// var btnName:String = aBtnNames[i]; // Refers to the i'th element of the array</span>
         <span style="color: #808080; font-style: italic;">// var btn:MovieClip = this[btnName] // Refers to a movieclip instance on stage with that name</span>
         <span style="color: #808080; font-style: italic;">// activateBtn(btn); // Passes the reference to that button to the activateBtn function</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> activateBtn<span style="color: #66cc66;">&#40;</span>btn:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
     <span style="color: #808080; font-style: italic;">// This is standard stuff i want all of my buttons to do:</span>
     btn.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;
     btn.<span style="color: #006600;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">true</span>;
     btn.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;
     btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OVER</span>, rollOverBtn<span style="color: #66cc66;">&#41;</span>;
     btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span>, rollOutBtn<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Of course, an even <em>better</em> way to handle this button situation is to create your own custom button class, but we&#8217;re taking baby steps here.  That&#8217;s the thing about code &#8211; these pieces we&#8217;re learning are like Lego blocks.  There are tons of different ways to build a sculpture out of Lego.  There are no &#8220;right&#8221; ways &#8211; only <em>preferred</em> ways.  Use this <b>Understanding &#8230;</b> series to get a grip on all the blocks you have to play with, and then &#8230; it&#8217;s time to play!</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_12_01/lego.jpg" alt="Lego Escher"></p>
<p>(We&#8217;ll work our way up to this.)
</p></div>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature.  </p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F01%2Funderstanding-loops-with-arrays%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F12%2F01%2Funderstanding-loops-with-arrays%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3224&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Understanding Loops</title>
		<link>http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 16:08:29 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3205</guid>
		<description><![CDATA[There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages. Loops are one of them. It&#8217;s a great idea to back up and read Understanding Arrays if you haven&#8217;t already. The reason is that Loops and Arrays go hand-in-hand. Loops are the interface [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very short list of programming structures you have to learn to be reasonably comfortable in most modern object-oriented languages.  Loops are one of them.</p>
<p>It&#8217;s a great idea to back up and read <a href="http://www.untoldentertainment.com/blog/2010/11/22/understanding-arrays/">Understanding Arrays</a> if you haven&#8217;t already.  The reason is that Loops and Arrays go hand-in-hand.  Loops are the interface we use to do interesting things with Arrays.  You might think of Arrays as an mp3 player, and Loops as headphones &#8230; if you try to use either of these things separately, they may not seem too terribly useful.  But put them together, and boy &#8230; <em>beautiful music</em> happens.  Unless you&#8217;re listening to Nickelback.</p>
<p>That&#8217;s why the next article in this series is called Understanding Loops <em>with</em> Arrays.  For now, just muscle through this article to understand what loops are all about &#8211; i&#8217;ll try to make it somewhat interesting.  The beautiful music starts playing in the next article.</p>
<h2>Pac Man</h2>
<p>Your code is usually chewed through, line by line, by an interpreter.  The interpreter is like Pac Man.  It eats the first line, and carries out its instructions. Then it eats the second line and carries out those instructions and so on, until the end of your program.  Earlier programming languages had each statement numbered, and the Pac Man code interpreter would chew through each one.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/basic.jpg" alt="Commodore Basic"></p>
<p>Goodness knows what &#8220;poke&#8221; meant in the cocaine-fueled days of the 1980&#8242;s.
</p></div>
<p>Object-oriented programming (OOP) does away with those line numbers and sends Pac Man flying all over the maze a little bit, jumping into and out of chunks of code.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/map.jpg" alt="Pac Man Map"></p>
<p>If procedural code with line numbers is like traveling by train on a straight track, OOP is like taking multiple plane flights through TIME PORTALS.
</p></div>
<p>But imagine for a second that your Pac Man code interpreter has to eat straight down the page to the bottom, to the last line of code.  If you want to do things more than once, you have to write the command more than once:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// This is pseudo-code, which means you can't really copy/paste it and expect it to work,</span>
<span style="color: #808080; font-style: italic;">// but it's very readable.</span>
eat a power pellet;
eat a power pellet;
eat a power pellet;</pre></div></div>

<p>Fine.  Pac Man eats a power pellet three times.</p>
<h2>Hungry Hungry Pac Man</h2>
<p>But what happens if your code interpreter needs to do something <em>more</em> than three times?  Say, fifty times.  Or a <em>thousand</em>?  Now you&#8217;re going to have that same line repeated a thousand times down the screen.  Yuck.</p>
<p>Or even worse, let&#8217;s say there are a number of instructions we want to carry out, and we want that set of instructions repeated:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// This is pseudo-code, which means you can't really copy/paste it and expect it to work,</span>
<span style="color: #808080; font-style: italic;">// but it's very readable.</span>
eat a power pellet;
give Ms. <span style="color: #006600;">Pac</span> Man a smooch;
punch a ghost <span style="color: #b1b100;">in</span> the face;
&nbsp;
eat a power pellet;
give Ms. <span style="color: #006600;">Pac</span> Man a smooch;
punch a ghost <span style="color: #b1b100;">in</span> the face;
&nbsp;
eat a power pellet;
give Ms. <span style="color: #006600;">Pac</span> Man a smooch;
punch a ghost <span style="color: #b1b100;">in</span> the face;</pre></div></div>

<p>Now you&#8217;ve got a real problem.  Your little set of instructions, repeated a thousand times, adds three thousand lines to the code &#8211; four thousand with line breaks.  This code becomes ridiculous to manage and maintain, it looks ugly, and it takes up way too much room.</p>
<p>Enter that frustrated mom from every infomercial ever: &#8220;There&#8217;s <em>got</em> to be a better way!&#8221;</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/clingFilm.jpg" alt="Plastic wrap is hard"></p>
<p>Plastic wrap is HARD!
</p></div>
<p>Loops are the better way.  You build them to make the interpreter repeat an instruction, or set of instructions, a bunch of times.  When the loop is done, the interpreter continues on its merry way down the page, chewing through each subsequent instruction you&#8217;ve written for it.</p>
<h2>The Anatomy of a Loop</h2>
<p>Here&#8217;s what a loop (often called a &#8220;for&#8221; loop) looks like in Actionscript 3 and other ECMA-based languages:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Let&#8217;s break it down piece by piece.</p>
<p>You&#8217;ll notice there are two sections: the declaration line, and those curly braces.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/loop1.jpg" alt="Two main loop sections"></p>
</div>
<p>The instructions you want to repeat go in between those curly braces, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    eat a power pellet;
    give Ms. <span style="color: #006600;">Pac</span> Man a smooch;
    punch a ghost <span style="color: #b1b100;">in</span> the face;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>That declaration line looks pretty hairy, though.  Let&#8217;s break it down.</p>
<p>Notice that the whole thing is just the word &#8220;for&#8221; followed by open and closed round brackets.  If we completely gut the loop, it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Doesn&#8217;t look so scary any more, yeah?</p>
<p>The stuff between the round brackets is split up into three sections: </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/loop2.jpg" alt="Loop header breakdown"></p>
</div>
<ol>
<li>Start here.
<li>Keep looping as long as this is true.
<li>Do this after every run through the loop.
</ol>
<p>The first and second sections are separated by a semi-colon, which is the dot-above-the-comma symbol that we usually use to end our statements.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/punctuation.jpg" alt="Names of common punctuation marks"></p>
</div>
<h2>1. Start Here</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/loopsStartHere.jpg" alt="Loops start here"></p>
</div>
<p>A &#8220;run&#8221; through a loop is called an <b>iteration</b>.  In order to keep count of how many times we&#8217;ve looped, we use a variable called an <b>iterator</b>.  Because the word &#8220;iterator&#8221; starts with the letter &#8220;i&#8221;, it&#8217;s common practice to use &#8220;i&#8221; as the iterator variable name.</p>
<p>So you need to declare and define that variable first, to give your loop a starting point.  Depending on how picky your language is, you may have to type the variable (give it a datatype).  Here are two examples of loops written in a permissive vs. strict language:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Permissive, like Unity javascript:</span>
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Strict, like Actionscript 3:</span>
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So the only real difference is that in the stricter language, we had to declare the iterator variable using the &#8220;var&#8217; keyword, and we had to expressly say that it was an integer datatype (whole number) by adding &#8220;:int&#8221; to the end of the variable name.</p>
<p>Note that you can also <b>declare</b> the iterator outside the loop, and <b>define</b> it inside the loop header:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>i like doing this, because it makes my loop header look cleaner. If i have more than one loop in my program, the compiler throws an error if i use the <b>var</b> keyword to declare the iterator more than once.  That means that if i quickly copy/paste a loop where the iterator is delcared inside the header, the compiler yells at me:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">20</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// ERROR!  You've already declared a variable called i, dummy.</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Meanwhile, this does not throw an error:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">20</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// No error. We're just resetting i to zero.</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>What this section does is set the value of a variable called i to zero. <b>i is our counter that will keep track of how many times we&#8217;ve run through the loop.</b></p>
<p>Now, onto the second section of that confusing header.</p>
<h2>2. Keep looping as long as this is true.</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/loopsKeepLooping.jpg" alt="Loops keep looping"></p>
</div>
<p>Every time the Pac Man interpreter starts to chew through this loop, he&#8217;s going to check the second section.  This section tells him &#8220;you&#8217;re okay to chew through this loop, as long as this statement <b>resolves</b> to true.&#8221;</p>
<p>What do i mean by &#8220;resolves&#8221;?  Imagine you take a bunch of ingredients and put them in a pan, and then bake what&#8217;s in the pan.  You&#8217;ve <em>resolved</em> the ingredients into a cake.  In the same way, we&#8217;re going to <em>resolve</em> the ingredients in this statement until they result in either <b>true</b> or <b>false</b>.</p>
<p>Here&#8217;s an easy one:</p>
<p>3<5</p>
<p>That statement resolves to <b>true</b>, because 3 is less than 5.  But this statement:</p>
<p>3>5</p>
<p>resolves to <b>false</b>, because 3 is not greater than 5.  These are the same rules we follow when we&#8217;re setting up conditional if statements.  If you need a review, check out Understanding Operators,  and Understanding Conditionals.  (note: i haven&#8217;t written these articles yet, but they&#8217;re on the way!)</p>
<p>Things get a touch more complicated when variables are involved.  Take this statement:</p>
<p>i<5</p>
<p>That's not as straightforward. i is the name of a variable (a bucket) that holds a value.  Whether this statement resolves to true or false really depends on the value of i.  If the value of i is 3, the statement resolves to true.  But if the value of i is 867, the statement resolves to false.</p>
<p>You can put all kinds of complicated nonsense into the second section of your loop header.  Regard:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; <span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1000</span> <span style="color: #66cc66;">&amp;&amp;</span> theSunIsShining<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> dogsLoveBacon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>In English, that second section now reads &#8220;run through the loop as long as the value of i is less than one thousand and the value of theSunIsShining is true, OR if the function dogsLoveBacon returns true.</p>
<p>Gross!  Let&#8217;s keep it simple.  When i was first learning programming, i&#8217;d sometimes write very complicated loop limiters, and i&#8217;d always regret it.  It&#8217;s rare that you see anything beyond a simple <b>i<something</b> in this second section.</p>
<h2>3. Do this after every run through the loop.</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/loopsDoThis.jpg" alt="Loops do this after every iteration"></p>
</div>
<p>The third and final section of the loop header tells the interpreter what to do after it chews through the last statement inside the curly braces of the loop.  The interpreter gets to the bottom, does whatever is in the third section, and then checks the second section to see if it should run through the loop again.  (If that&#8217;s confuding, don&#8217;t worry &#8211; we&#8217;ll take a closer look at that process in a moment.)</p>
<p>In most cases, this third section will say i++.  That&#8217;s the <b>increment</b> operator, which is code shorthand for saying &#8220;add 1 to the value of i&#8221;.  So every time through the loop, the counter goes up by one.</p>
<p>Again, you can make this bit crazy complicated if you like.  You could say something like i+=Math.sqrt(beesHaveKnees()), which means &#8220;add the square root of the value returned by the beesHaveKnees function to the value of i&#8221;.  You can even comma-separate multiple statements by saying i++, j++, which means &#8220;increment the value of i, and also increment the value of j&#8221;.  You <em>can</em> do this, but in day-to-day vanilla programming, and especially just starting out, you&#8217;ll want to keep this stuff very, very simple.</p>
<h2>Follow the Interpreter Through the Loop</h2>
<p>So let&#8217;s trace the path of the Pac Man code interpreter through our loop.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process1.jpg" alt="Do the thing in the first section"></p>
</div>
<p>1. Do what&#8217;s in the first section first.  In this case, we set the value of the iterator variable <b>i</b> to zero.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process2.jpg" alt="Check the second section"></p>
</div>
<p>2. Check to see if the second section resolves to true.  </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process3.jpg" alt="Chew through the statement block"></p>
</div>
<p>3. If it does resolve to true, chew through all the statements in the statement block (the stuff between those curly braces). A power pellet gets eaten, Ms. Pac Man gets some lovin&#8217;, and a ghost gets his just desserts.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process4.jpg" alt="Execute the third section"></p>
</div>
<p>4. When you finish chewing through the last statement in order, do what&#8217;s in the third section.  In this example, we increase the value of i by one. The value of i (0) plus 1 equals 1, so the second time through the loop, i equals 1.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process5.jpg" alt="Check the second section again"></p>
</div>
<p>5. Check the second section to see if it resolves to true.  In our example, the value of i (1) is indeed less than 1000, so our interpreter should chew through all the statements in the loop body again.  He eats another power pellet, plants another kiss, and dispatches another ghost.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process6.jpg" alt="Loop 1000 times"></p>
</div>
<p>6.  Let&#8217;s pretend we&#8217;ve gone through the loop 1000 times.  Pac Man&#8217;s gluttony continues unabated, Ms. Pac Man struggles to cope with her husband&#8217;s relentless sexual advances, and his plan for spectral genocide is finally complete.   At the bottom of the loop, the value of i is 999.  (Note: it&#8217;s not 1000, because we started counting at zero)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process7.jpg" alt="Execute the third section"></p>
</div>
<p>7. The interpreter jumps to the top of the loop header, and does what&#8217;s in the third section. Adding 1 to the value of i puts it at 1000.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process8.jpg" alt="Check the second section"></p>
</div>
<p>8. The interpreter looks at the second section of the loop header to determine whether it should go through the loop again.  This time, i <em>is not</em> less than 1000. (1000 is not less than 1000.)  So because this statement resolves to <b>false</b>, the interpreter exits the loop, and continues after the closed curly brace at the bottom of the whole structure.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_23/process9.jpg" alt="Exit the loop"></p>
</div>
<p>9. Our Pac Man-like code interpreter exits the loop and smugly strikes a pose.</p>
<h2>A Real-World Example</h2>
<p>None of the code in this article will actually run properly, so here&#8217;s a chunk that will:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">5</span>; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The value of i is &quot;</span> + i<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>(If you want it to work in Unity javascript, change &#8220;trace&#8221; to &#8220;print&#8221; or &#8220;Debug.Log&#8221;, and you should see the results of the loop pop up in the Console window.)</p>
<p>As i mentioned off the top, loops on their own are very useful for keeping our programs down to a manageable size, but they really come alive when we combine them with Arrays.  In the next article, <a href="http://www.untoldentertainment.com/blog/2010/12/01/understanding-loops-with-arrays/">Understanding Loops with Arrays</a>, we&#8217;ll see how these two code constructs, when married, are a match made in programming heaven.  And if we&#8217;re lucky, we&#8217;ll even see Pac Man tried as a war criminal.  Join me, won&#8217;t you?</p>
<p>For more Flash AS3 Tutorials and a pile of other useful stuff, check out our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript 911</a> feature. </p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F11%2F24%2Funderstanding-loops%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F11%2F24%2Funderstanding-loops%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3205&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/11/24/understanding-loops/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>My Prescription for (More) Successful Students</title>
		<link>http://www.untoldentertainment.com/blog/2010/11/10/my-prescription-for-more-successful-students/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/11/10/my-prescription-for-more-successful-students/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 06:04:01 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Canadian Media News]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=3129</guid>
		<description><![CDATA[i keep a keen eye on the post-secondary education system here in Ontario. i&#8217;d LOVE to get to a place where we have a number of really fantastic schools teaching video game design and development, and Ontario&#8217;s where you gotta go when you&#8217;re considering a career in this stuff. But we&#8217;ve got a long way [...]]]></description>
			<content:encoded><![CDATA[<p>i keep a keen eye on the post-secondary education system here in Ontario.  i&#8217;d LOVE to get to a place where we have a number of really fantastic schools teaching video game design and development, and Ontario&#8217;s where you gotta go when you&#8217;re considering a career in this stuff.   But we&#8217;ve got a long way to go.</p>
<p>When <a href="http://www.untoldentertainment.com/blog/2010/08/30/toronto-fan-expo-2010-state-of-the-toronto-game-industry-panel/">i spoke at the Toronto FanExpo</a>, one of the audience members asked me about value-for-money in these programs.  i responded the same way i always do: <b><em>if you are in a college video game development program, and you do not graduate with at least one finished game, demand your money back.</em></b>  (Bolded AND italicized &#8230; this guy means BIDNESS.)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_10/business.jpg" alt="this guy means bidness"></p>
<p>(this guy also means bidness)
</p></div>
<p>Of course, a number of preventative factors could be involved in you not having a finished game. (YOU, for example.) But if it&#8217;s not the goal of your <em>game development school</em> to launch you with a final, playable game, i question your school&#8217;s priorities (and their motives in taking your parents&#8217; and/or taxpayers&#8217; heard-earned money to put you through the program).</p>
<h2>Press Rx to Start</h2>
<p>i have a prescription for graduating students: three simple things that many, <em>many</em> grads don&#8217;t have.  By checking these three things off the list, you&#8217;ll be miles ahead of most of the other Ontario game dev grads against whom you&#8217;ll be competing for a very limited number of internships, entry-level positions and other opportunities. These three things are:</p>
<ol>
<li>Your own website.
<li>A finished game on that website, <em>playable in the browser.</em>
<li>Business cards, to drive people to that website when you&#8217;re out at networking events.
</ol>
<h2>1. Your Own Website</h2>
<p>Here are a few DO&#8217;s and DONT&#8217;s for your own website:</p>
<p><b>DO</b></p>
<ul>
<li>buy a domain (many web hosts give you one for free with a hosting package)
<li>create an email address using that domain (example: pete@petesWebsite.com)
<li>make your CV/resume readily accessible on the site, BUT &#8230; despite what your college tells you in their &#8220;career preparedness&#8221; filler course, your resume isn&#8217;t really worth a damn in this industry.  The proof is in the (playable) pudding &#8211; your <em>finished</em> work samples.
<li>have a prominent link that says &#8220;Contact&#8221; which, when clicked, displays your phone number and email address.  (Afraid you&#8217;ll be harassed by stalkers?  Get over yourself.  You won&#8217;t.)
</ul>
<p><b>DON&#8217;T</b></p>
<ul>
<li>go with a free hosting solution (example: http://pete.awesomeSitesForFree.com)
<li>bury your best work behind more than one click (preferably, your reel or finished game should be front and center on the main page, playable in one click)
<li>hide your contact info
<li>prominently post your resume (Your resume doesn&#8217;t matter. Your work does.)
<li>post all of your school projects, down to your Illustrator colour wheel and your Photoshop person-removal exercise.  Just pick two or three of your very best pieces, and leave the rest out.  If you don&#8217;t have anything you can confidently show, go back to the drawing board and build something.  Doesn&#8217;t matter if you&#8217;ve just graduated &#8211; your portfolio is never finished, and if it sucks right now, stop looking so hard for a job in the industry.  Get a joe job to keep yourself occupied, and spend every remaining waking hour making your portfolio not suck.
</ul>
<h2>2. A Finished Game, Playable in the Browser</h2>
<p>By &#8220;playable in the browser&#8221;, we&#8217;re talkin&#8217;:</p>
<ul>
<li>Flash
<li>Unity
<li>HTML5
<li>&#8230; Java?  (Is it playable in the browser?  i *think* so. i don&#8217;t know enough about it to say for sure.)
<li>Shockwave (if you&#8217;ve decided to go back in time to 1998)
</ul>
<p>i may draw a lot of fire by stipulating that the game must be playable in the browser, but i&#8217;m standing behind it as stone cold fact: if your game is a downloadable executable file, <em>it will not get played</em>.</p>
<p>The <em>last</em> thing i want to do as an employer is spend time futzing around with a student&#8217;s (potentially) badly-built file that may do God-knows-what kind of damage to my system.  Add to that the time involved in screening applicants. i just don&#8217;t have the hours or the patience, and i know i&#8217;m not alone in that.  At the <a href="http://www.untoldentertainment.com/blog/2010/09/25/indie-showcase-caps-a-packed-week-in-toronto/">Indie Showcase</a> event in Toronto, <a href="http://www.tojam.ca">TOJam</a> founder Jim McTellin&#8217;ItLikeItIs McGinley confirmed that the TOJam games that are not playable in the browser receive dramatically fewer (read: ZERO) plays than their playable-in-browser counterparts.</p>
<p>But if i hit a student&#8217;s site, and right there on the main page is a finished game with a big, inviting PLAY button, i will click and try it out for at least a few seconds.</p>
<h2>No Game? Fake it.</h2>
<p>If you can&#8217;t swing a browser-playable game, create a trailer for the game featuring gameplay. Watch different pieces on <a href="http://www.gametrailers.com">GameTrailers.com</a> to get a sense of good pacing and high production values, and steal whatever techniques you can identify.  And whether you have a browser-playable game or not, be sure to add a few clickable, biggify-able screenshots to your site in case the visitor can&#8217;t be arsed to hit that PLAY button on your video or game.</p>
<h2>On a Role</h2>
<p>Another tip: it&#8217;s preferable to have a game that you either built on your own, or where your role was very clearly defined (example: you created all of the background art, and programmed and designed the entire user interface).  It&#8217;s fine if the game was a collaborative effort, but it becomes more difficult for a visitor to get a sense of your abilities.  YOUR abilities &#8211; those are the things you need to be trumpeting on your site.  If the game was a team project, clearly and prominently state your role in the project &#8211; the more specific the better.</p>
<blockquote><p><b>GOOD</b>:</p>
<p>I created the sprite sheets for the main character, and the warg and vampire villains.  I also did all the sound design except the background music tracks.   </p></blockquote>
<blockquote><p><b>NOT SO TERRIBLY GOOD:</b></p>
<p>I worked on this project with seven others. I designed some of it, and drew some of the art.  I also did about half of the coding, and some of the animation.  (wtf does &#8220;half the coding&#8221; mean?)</p></blockquote>
<h2>3. Business Cards</h2>
<p>They say &#8220;it&#8217;s all who you know&#8221;, so a very crucial part of being a graduate is getting out there and networking.  i guarantee you that if you impress someone with your personality at an event and ask him to remember to visit petesWebsite.com, it ain&#8217;t gonna happen.  People at networking events have memories like sieves &#8211; you&#8217;re one of maybe thirty people they&#8217;re going to talk to, and you&#8217;re a recent grad, so it&#8217;s likely more of a challenge for you to make an impression.  You&#8217;re gonna need business cards.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_11_10/americanPsycho.jpg" alt="American Psycho"></p>
<p>Make sure it has off-white colouring, tasteful thickness, and  &#8211; oh my God &#8211; a watermark!
</p></div>
<p>Here are a few things i recommend listing on your business card:</p>
<ol>
<li>your name
<li>your email address @ <em>your own domain</em>
<li>your phone number
<li>some kind of tag line that reminds the reader of your goals as a recent grad, and be specific (example: Peter Peterson &#8211; Seeking Employment as a 3D Texture Artist in the Mobile Game Industry)
<li>your website address &#8230; make sure it doesn&#8217;t take too long to type, like untoldentertainment.com (what a bloody terrible idea THAT url was)
<li>Some kind of call to action can&#8217;t hurt (example: Come see my dragon models!  or Come play Super Jumpy Man!).  If you put something like that on there, you may pique my interest.
</ol>
<p>And a few don&#8217;ts:</p>
<ol>
<li>don&#8217;t bog the card down with a million phone numbers. One will do.  If you really can&#8217;t be reached at that number all the time, you can put two phone numbers on there, but try to keep it simple.
<li>i don&#8217;t recommend putting your mailing address on there.  No one&#8217;s going to send you a letter by Pony Express.  Not only that, but you risk looking like a hick if you&#8217;re applying for work in the big city, and your business card places you in some distant suburb or outlying area (it ain&#8217;t pretty, but i wouldn&#8217;t recommend passing around an Oshawa or Barrie business card at a Toronto networking event.  You want to appear as if you&#8217;re local and available, and as if you have all your teeth.)
<li>don&#8217;t don&#8217;t don&#8217;t don&#8217;t don&#8217;t list a hotmail address.  You&#8217;ll look bush-league.  i&#8217;d even say the same for gmail addresses &#8230; you own a domain, so you should use that in your address.  If you like the gMail service, you can manage your @petesWebsite mail using gMail. Your public-facing address should be customized.
<li>don&#8217;t cook up some bogus company name.  If you&#8217;re looking for a full-time salaried position at a company, i think it&#8217;s better to present yourself as an individual.  It&#8217;s more important that people know Pete Peterson, than &#8220;Layzor Virtutronic Game Design Systems Inc.&#8221;
</ol>
<p>i&#8217;d love to get your suggestions for web hosts and business card tips in the comments section!  And feel free to complain about my browser-only stipulation for the games.  i&#8217;ll just let you know ahead of time: you&#8217;re wrong.
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F11%2F10%2Fmy-prescription-for-more-successful-students%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F11%2F10%2Fmy-prescription-for-more-successful-students%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/11/10/my-prescription-for-more-successful-students/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=3129&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/11/10/my-prescription-for-more-successful-students/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Unity 3D Game Development by Example is Now Available for Pre-Order</title>
		<link>http://www.untoldentertainment.com/blog/2010/09/10/unity-3d-game-development-by-example-is-now-available-for-pre-order/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/09/10/unity-3d-game-development-by-example-is-now-available-for-pre-order/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 18:27:44 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Company News]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2899</guid>
		<description><![CDATA[Omigosh! i haven&#8217;t been THIS excited since that truck full of (inexplicably) fully-inflated bouncy castles collided with that shipment of Nerf guns on the highway. The first book that i ever paid unskilled labourers from the Philippines to write for me, Unity 3D Game Development by Example, is now available for pre-order on the Pack [...]]]></description>
			<content:encoded><![CDATA[<p>Omigosh!  i haven&#8217;t been THIS excited since that truck full of (inexplicably) fully-inflated bouncy castles collided with that shipment of Nerf guns on the highway.  The first book that i ever paid unskilled labourers from the Philippines to write for me, <b><a href="https://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book">Unity 3D Game Development by Example</a></b>, is now available for pre-order on the Pack Publishing website!</p>
<div class="displayed">
<p><a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881"><img src="http://www.untoldentertainment.com/blog/img/2010_09_10/unity3DByExample.jpg"></a></p>
<p><a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881">Pre-order your copy today!</a>
</div>
<p>Of course, the cover is still a work in progress.  i&#8217;ve made a few suggestions to the publisher of what i&#8217;d like to see.  For example, here&#8217;s a mock-up of the cover with a cat singing karaoke:</p>
<div class="displayed">
<p><a href="http://www.packtpub.com/unity-3d-game-development-by-example-beginners-guide/book/mid/2709105s93kf?utm_source=untoldentertainment.com&#038;utm_medium=affiliate&#038;utm_content=authorsite&#038;utm_campaign=mdb_004881"><img src="http://www.untoldentertainment.com/blog/img/2010_09_10/unity3DByExampleKaraokeCat.jpg"></a></p>
<p>Nice job, Karaoke Cat, but it was a bit pitchy towards the end.
</p></div>
<div class="mc_error_msg">
			There was a problem loading your MailChimp details. Please re-run the setup process under Settings-&gt;MailChimp Setup		</div>
<p>i&#8217;ve written a FAQ for the book.  At last, all your burning questions will be answered:</p>
<h2>What is Unity 3D?</h2>
<p>Unity 3D is a game engine that&#8217;s been around for only a few years, but is rapidly gaining steam.  It&#8217;s a tool that enables you to create your own 3D (or, with effort, 2D) games.  You can deploy your games to the browser.  That&#8217;s right: after a quick ~3MB plugin download, people can play your full 3D game <em>right inside the browser</em>, without having to download and install an .exe.  If you want people to visit your portfolio site and play your games instantly, Unity 3D is the tool for you.</p>
<h2>Can I Only Deploy to the Web?</h2>
<p>No &#8211; the main Unity engine allows you to create standalone game files that will run on PC and Mac.  If you purchase additional licenses, you can target the iPhone/iPod/iPad and WiiWare. Upcoming support has been announced for Android and Xbox Live Arcade (but keep in mind that you&#8217;ll still have to be a developer in good standing with Nintendo or Microsoft to develop for their consoles &#8211; it&#8217;s not a path you&#8217;ll likely take if you&#8217;re a hobbyist.)</p>
<h2>How Much Does Unity Cost?</h2>
<p>There are two versions of the core engine.  Unity is free, while Unity Pro costs.  Unity lacks a few features of Unity Pro, most notably real-time shadows and video playback support. (note: this lack of features is definitely not something that would get a beginner in much of a twist.)  Games created with Unity are prefaced with a Unity-branded splash screen.  You can check out a <a href="http://unity3d.com/unity/licenses">Unity license comparison grid here</a>. </p>
<p>Beyond those restrictions, you&#8217;re free to make as many games as you like with the free version of Unity without paying a single cent to the engine authors.  This is in contrast to UDK (Unreal Development Kit), Unity&#8217;s main competitor, which starts clawing back cash at (comparitively) alarming rates if you sell a certain number of copies. </p>
<h2>I like Flash. Will I Like Unity?</h2>
<p>Oh, yes!  There are many similarities between the two programs.  The biggest difference is that Flash is a <em>content creation tool</em> that people manhandle to the point where you can make games with it, while Unity 3D is a dedicated <em>game engine</em>. That means that it includes a lot of game systems right out of the box: physics, collision detection, 3D rendering and particle systems, to name a few.</p>
<p>Check out our <a href="http://www.untoldentertainment.com/blog/2009/09/25/five-common-as3-to-unityscript-translations/">Five Common AS3 to UnityScript Translations</a> article in our <a href="http://www.untoldentertainment.com/blog/unity-nuub/">Unity Nuub</a> section.</p>
<h2>What&#8217;s in the Book?</h2>
<p>Unity 3D Game Development by Example contains lessons, code and art assets to build four very simple games in the engine: a keep-up game, a catch game, a memory game and a space shooter. These lessons are written in very plain language with lots of analogies and plenty of pictures, so that readers who have never coded or used a game engine in their lives will be able to get these projects off the ground.  Certain elements, like the three countdown clocks in Chapter 7, are presented as standalone pieces that you can integrate into your games as you like.  The book teaches you how to build standard game bits &#8211; title screens, buttons, timers, collision scripts, sound effects triggers, and endgame scenarios &#8211; that you can remix into your own projects.</p>
<h2>Is This Book Appropriate to Use as a Text Book for my College or High School Game Design Program?</h2>
<p>Absolutely. Please contact Packt Publishing for volume sales.</p>
<h2>Is It Available As an e-Book?</h2>
<p>Yes.</p>
<h2>I Enjoy Murdering Trees.  Is It Available as a Book Book?</h2>
<p>Yes.</p>
<h2>What Language is the Book Written In?</h2>
<p>English, currently.  All code examples are in javascript.  Unity supports three different languages: javascript, C# and BOO. i chose javascript for the book because most of the online examples and tutorials i&#8217;ve come across are in javascript. It&#8217;s probably the best choice for a beginner. </p>
<h2>What&#8217;s the Difference Between This Book and Unity Game Development Essentials by Will Goldstone?</h2>
<p>Will&#8217;s also written a great beginner book &#8211; the <a href="https://www.packtpub.com/unity-game-development-essentials/book">first Unity 3D book on the market</a> &#8211; that you should definitely check out.  Will&#8217;s book contains one large open-world project with a number of smaller activities inside of it.  My feeling was that open-world games open a whole can of worms that could potentially overwhelm someone new to Unity (what happens when you walk out into the water?  What if you get stuck inside a volcano?). My focus was on keeping things simple and manageable, so that you can start with a very controlled and fully-functional project, and ramp up from there as your skills increase.  </p>
<h2>What&#8217;s the Difference Between This Book and an Riding Down an Exhilharating Waterslide on the Back of a Unicorn?</h2>
<p>Not much. </p>
<h2>Preface and Chapter Listing</h2>
<p>By request, here is an excerpt from the book&#8217;s Preface:</p>
<blockquote><p>
&#8220;Game Developer&#8221; has rapidly replaced &#8220;firetruck&#8221; as the number one thing that kids want to be when they grow up. Gone are the days when aspiring developers needed a university education, a stack of punch cards, and a room-sized computer to program a simple game. With digital distribution and the availability of inexpensive (or free) games development tools like Unity 3D, the democratization of game development is well underway.</p>
<p>But, just as becoming a firetruck is fraught with perils, so too is game development. Too often, aspiring developers underestimate the sheer enormity of the multidisciplinary task ahead of them. They bite off far more than they can chew, and eventually drift away from their game development dreams to become lawyers or dental hygienists. It&#8217;s tragic. This book bridges the gap between &#8220;I wanna make games!&#8221; and &#8220;I just made a bunch of games!&#8221; by focusing on small, simple projects that you can complete before you reach the bottom of a bag of corn chips.</p>
<p><b>What this book covers</b></p>
<p><em>Chapter 1, That&#8217;s One Fancy Hammer!</em>, introduces you to Unity 3D—an amazing game engine that enables you to create games and deploy them to a number of different devices, including (at the time of writing) the Web, PCs, iOS platforms, and WiiWare, with modules for Android and Xbox Live Arcade deployment in the works. You&#8217;ll play a number of browser-based Unity 3D games to get a sense of what the engine can handle, from a massively-multiplayer online game all the way down to a simple kart racer. You&#8217;ll download and install your own copy of Unity 3D, and mess around with the beautiful Island Demo that ships with the product.</p>
<p><em>Chapter 2, Let&#8217;s Start with the Sky</em>, explores the difference between a game&#8217;s skin and its mechanic. Using examples from video game history, including Worms, Mario Tennis, and Scorched Earth, we&#8217;ll uncover the small, singular piece of joy upon which more complicated and impressive games are based. By concentrating on the building blocks of video games, we&#8217;ll learn how to distil an unwieldy behemoth of a game concept down to a manageable starter project.</p>
<p><em>Chapter 3, Ticker Taker</em>, puts you in the pilot seat of your first Unity 3D game project. We&#8217;ll explore the Unity environment and learn how to create and place primitives, add Components like physic materials and rigidbodies, and make a ball bounce on a paddle using Unity&#8217;s built-in physics engine without ever breaking a sweat.</p>
<p><em>Chapter 4, Code Comfort</em>, continues the keep-up game project by gently introducing scripting. Just by writing a few simple, thoroughly-explained lines of code, you can make the paddle follow the mouse around the screen to add some interactivity to the game. This chapter includes a crash course in game scripting that will renew your excitement for programming where high school computer classes may have failed you.</p>
<p><em>Chapter 5, Game#2: Robot Repair</em>, introduces an often-overlooked aspect of game development: &#8220;front-of-house&#8221; User Interface design—the buttons, logos, screens, dials, bars, and sliders that sit in front of your game—is a complete discipline unto itself. Unity 3D includes a very meaty Graphical User Interface system that allows you to create controls and fiddly bits to usher your players through your game. We&#8217;ll explore this system, and start building a complete two-dimensional game with it! By the end of this chapter, you&#8217;ll be halfway to completing Robot Repair, a colorful matching game with a twist.</p>
<p><em>Chapter 6, Game#2: Robot Repair Part 2</em>, picks up where the last chapter left off. We&#8217;ll add interactivity to our GUI-based game, and add important tools to our game development tool belt, including drawing random numbers and limiting player control. When you&#8217;re finished with this chapter, you&#8217;ll have a completely playable game using only the Unity GUI system, and you&#8217;ll have enough initial knowledge to explore the system yourself to create new control schemes for your games.</p>
<p><em>Chapter 7, Don&#8217;t be a Clock Blocker</em>, is a standalone chapter that shows you how to build three different game clocks: a number-based clock, a depleting bar clock, and a cool pie wedge clock, all of which use the same underlying code. You can then add one of these clocks to any of the game projects in this book, or reuse the code in a game of your own.</p>
<p><em>Chapter 8, Ticker Taker</em>, revisits the keep-up game from earlier chapters and replaces the simple primitives with 3D models. You&#8217;ll learn how to create materials and apply them to models that you import from external art packages. You&#8217;ll also learn how to detect collisions between Game Objects, and how to print score results to the screen. By the end of this chapter, you&#8217;ll be well on your way to building Ticker Taker—a game where you bounce a still-beating human heart on a hospital dinner tray in a mad dash for the transplant ward!</p>
<p><em>Chapter 9, Game#3: The Break-Up</em> is a wild ride through Unity&#8217;s built-in particle system that enables you to create effects like smoke, fire, water, explosions, and magic. We&#8217;ll learn how to add sparks and explosions to a 3D bomb model, and how to use scripting to play and stop animations on a 3D character. You&#8217;ll need to know this stuff to complete The Break-Up—a catch game that has you grabbing falling beer steins and dodging explosives tossed out the window by your jilted girlfriend.</p>
<p><em>Chapter 10, Game#3: The Break-Up Part 2</em>, completes The Break-Up game from the previous chapter. You&#8217;ll learn how to reuse scripts on multiple different Game Objects, and how to build Prefabs, which enable you to modify a whole army of objects with a single click. You&#8217;ll also learn to add sound effects to your games for a much more engaging experience.</p>
<p><em>Chapter 11, Game #4: Shoot the Moon</em>, fulfills the promise of Chapter 2 by taking you through a re-skin exercise on The Break-Up. By swapping out a few models, changing the background, and adding a shooting mechanic, you&#8217;ll turn a game about catching beer steins on terra firma into an action-packed space shooter! In this chapter, you&#8217;ll learn how to set up a two-camera composite shot, how to use code to animate Game Objects, and how to re-jig your code to save time and effort.</p>
<p><em>Chapter 12, Action</em>, takes you triumphantly back to Ticker Taker for the coup de grace: a bouncing camera rig built with Unity&#8217;s built-in animation system that flies through a model of a hospital interior. By using the two-camera composite from The Break-Up, you&#8217;ll create the illusion that the player is actually running through the hospital bouncing a heart on a tin tray. The chapter ends with a refresher on bundling your project and deploying it to the Web so that your millions of adoring fans can finally experience your masterpiece.</p>
<p><b>What you need for this book</b></p>
<p>You&#8217;ll need to be in possession of a sturdy hat, a desk chair equipped with a seatbelt, and an array of delicious snack foods that won&#8217;t get these pages all cheesy (if you&#8217;re reading the e-book version, you&#8217;re all set). Early chapters walk you through downloading and installing Unity 3D (h<a href="ttp://unity3d.com/unity/download/">ttp://unity3d.com/unity/download/</a>). A list of resources and links to additional software can be found in the appendix.</p>
<p><b>Who this book is for</b></p>
<p>If you&#8217;ve ever wanted to develop games, but have never felt &#8220;smart&#8221; enough to deal with complex programming, this book is for you. It&#8217;s also a great kickstart for developers coming from other tools like Flash, Unreal Engine, and Game Maker Pro.
</p></blockquote>
<h2>What&#8217;s Next?</h2>
<p>Got any more questions?  Drop me a line in the comments section and i&#8217;ll answer them here.</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F09%2F10%2Funity-3d-game-development-by-example-is-now-available-for-pre-order%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F09%2F10%2Funity-3d-game-development-by-example-is-now-available-for-pre-order%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/09/10/unity-3d-game-development-by-example-is-now-available-for-pre-order/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2899&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/09/10/unity-3d-game-development-by-example-is-now-available-for-pre-order/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Toronto Fan Expo 2010: State of the Toronto Game Industry Panel</title>
		<link>http://www.untoldentertainment.com/blog/2010/08/30/toronto-fan-expo-2010-state-of-the-toronto-game-industry-panel/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/08/30/toronto-fan-expo-2010-state-of-the-toronto-game-industry-panel/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 12:55:52 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Awesomazing]]></category>
		<category><![CDATA[Canadian Media News]]></category>
		<category><![CDATA[Company News]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2840</guid>
		<description><![CDATA[i felt really honoured to be invited to speak on a panel at the Toronto Fan Expo this weekend alongside a number of other local industry pros. i couldn&#8217;t attend the event as a non-cosplayer, so my wife Cheryl whipped up a little something to satisfy my desperate desire for attention, and my business need [...]]]></description>
			<content:encoded><![CDATA[<p>i felt really honoured to be invited to speak on a panel at the Toronto Fan Expo this weekend alongside a number  of other local industry pros.  i couldn&#8217;t attend the event as a <a href="http://www.untoldentertainment.com/blog/2010/08/28/toronto-fan-expo-2010-non-cosplayers-gallery/">non-cosplayer</a>, so my wife Cheryl whipped up a little something to satisfy my desperate desire for attention, and my business need to extend the Untold Entertainment brand in ridiculous ways:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/ryanHensonCreighton.jpg" alt="Ryan Creighton's red monster hat"></p>
</div>
<p>The panel was moderated by Jason MacIsaac of Electric Playground fame, late himself of a small Ontario game studio from the Niagara region called Cerebral Vortex Games.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/panel.jpg" alt="Fan Expo State of the Game Industry Panel"></p>
</div>
<p>My fellow guests on the panel were (from right):</p>
<ul>
<li>Ian Kelso, head of <a href="http://interactiveontario.com/">interactiveontario</a>
<li>Leslie Phord-Toy, a producer at <a href="http://en.wikipedia.org/wiki/Horsez">UbiSoft&#8217;s</a> new Toronto Studio
<li>Ryan MacLean, formerly of Pseudo Interactive and a founder of <a href="http://www.drinkboxstudios.com/main/news.php">Drinkbox Studios</a> (also both the second Mac and the second Ryan on the panel)
<li>Philippe McNally, from <a href="http://www.longbowgames.com/">Longbow Digital Arts</a>, who recently released their PC RTS Hegemony: Philip of Macedon
</ul>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/line.jpg" alt="Fan Expo Line-up"></p>
</div>
<p>i was thrilled to see that the line-up for the talk was substantial. A Fan Expo staff member asked us if we were okay with people sitting on the floor when we ran out of seats. Of course, Ubi Soft was the big draw, as many of the audience members wanted to know how to get a job there working on their favourite triple-A console franchises. i made a point to mention that UbiSoft also developed the Nintendo DS Babiez/Petz/Horsez games, as well as a number of cash-in movie licenses that have failed to pull in the same acclaim as their more well-known blockbusters.</p>
<p>i&#8217;m doing my best to end this (apparently prevalent) notion that working in the video game industry is the ultimate fulfillment of this masturbatory <em>Tom Hanks in BIG</em> fantasy everyone has.  Bills gotta get paid, and you may be asked to (gasp!) work on something you don&#8217;t like, such as a (shock!) video-heavy bank website instructing visitors on the various retirement products available to them (as we did last year).</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/ian.jpg" alt="Ian Kelso"></p>
<p>Most people were delighted to see Ian, who they mistakenly thought was cosplaying as either Lex Luthor, Professor Xavier, Kratos, Captain Jean-Luc Picard, John Locke from LOST, or as a member of the Blue Man Group after a bath.
</p></div>
<h2>Half-Remembered Q &#038; A</h2>
<p>i admit, i&#8217;m having a hard time remembering what went on at the panel.  There was a girl in the second row wearing an incredibly distracting Slave Leia costume, so i think most of what i had to say was along the lines of &#8220;hummina hummina hummina.&#8221;  (Slave Leia costumes don&#8217;t usually do it for me, but this one was worth strangling your hutt over.)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/slaveLeia.jpg" alt="Toronto Fan Expo 2010 Slave Leia"></p>
<p>Alternate Star Wars masturbation euphemism: HAND SOLO.
</p></div>
<p>So the pro reporters will definitely cover the panel better, but here are a few questions and answers that i <em>can</em> recall:</p>
<p><b>Q:</b>Why develop games in Toronto?<br />
<b>A:</b>Lesley&#8217;s answer was no secret &#8211; Ubi was attracted by the tax credits and government funding.  Ian hinted that interactiveontario and the government are trying to secure at least one more &#8220;whale&#8221; to move into the province.  For the three small developers, the answer was &#8220;intertia&#8221;.  Our families are here, we live here, and for folks like me who have young kids and ties to grandparents, it&#8217;s very difficult to seek our fortunes elsewhere.  Ian added that the work they&#8217;re doing to attract big companies helps heal the brain drain; if Lesley were to leave UbiSoft (for example), he wants enough studio muscle here to retain top talent in the province.</p>
<p><b>Q:</b>Does your choice of school make you more or less employable?<br />
<b>A:</b>Ryan M seemed to be more impressed by educational pedigree, saying that it was not the only thing he looks for, but that it is an indicator of a qualified applicant.  The only &#8220;good&#8221; Ontario schools mentioned were Waterloo, Sheridan, and University of Toronto.  There are many, many schools that aren&#8217;t on that short top-of-mind list, including yours. Reflect on that.</p>
<p>i took a few digs at the International Academy of Design and Technology, saying that nearly everyone i&#8217;ve known from that school &#8211; both students <em>and</em> faculty &#8211; bad-mouthed the place (and forgetting that the moderator had been an instructor there &#8211; oops).  Despite the school&#8217;s rock-bottom reputation, i&#8217;ve hired two programmers in my stint as a studio owner, and they&#8217;ve both been IADT grads.  For me, individual excellence beats a school&#8217;s bad rep.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/fire-eater.jpg" alt="flaming torch juggler"></p>
<p>i&#8217;m not bothered that this guy is an IADT grad. The moment we need a flaming torch juggler, he&#8217;s hired.
</p></div>
<p><b>Q:</b> Why aren&#8217;t more studios embedding themselves in schools to cherry-pick the best talent?<br />
<b>A:</b>(no one really weighed in on this, but i gave it a shot at a local community college this year with <a href="http://www.untoldentertainment.com/blog/2010/02/18/whats-wrong-with-ontario-colleges-part-1/">disastrous</a> <a href="http://www.untoldentertainment.com/blog/2010/02/23/whats-wrong-with-ontario-colleges-part-2/">results</a>)</p>
<p><b>Q:</b>How do you get a job in the industry?<br />
<b>A:</b>The panel agreed that portfolios were really important.  Ryan M said that demonstrated capability trumps a fancy CV.  Philippe liked to see evidence of problem-solving ability.  i said i&#8217;d much prefer a candidate with a portfolio of a few finished games he&#8217;d created himself, rather than a student project he completed with a number of classmates.</p>
<p><b>Q:</b>Why don&#8217;t more companies take interns?<br />
<b>A:</b>The three indies &#8211; Philippe, Ryan M and myself &#8211; said that interns were a risky proposition for small studios, due to the resources they demand. Leslie said that Ubi takes interns (theirs was in the front row taking pictures), but that the intern would have to have something valuable to commit to the organization.</p>
<p>One thing i didn&#8217;t get a chance to say was that people should be very wary of schools that offer internships.  Picture it: you&#8217;re a college program head, and your school has guaranteed this placement program.  You&#8217;ve got a few great students, a handful of middling ones, and two or three absolute morons who have barely managed to squeak by.  Do you really want your school&#8217;s reputation stymied by those guys?  Do you really want to risk damaging your relationship with industry by sending them out on a placement?  No, you don&#8217;t.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/moron.jpg" alt="duh"></p>
<p>Uh &#8230; hello, UbiSoft? We have a student who&#8217;d like to complete his placement in your shop.
</p></div>
<p>Add to that the fact that there are very few shops in town, compared with the number of schools cranking out game-trained grads (Humber, Waterloo, George Brown, Durham, U of T, UOIT, Ryerson, Trios, Sheridan, Seneca, York, and Max the Mutt off the top of my head).  Some schools churn grads as often as every six months. There&#8217;s a clear internship supply-and-demand problem here.</p>
<p>That&#8217;s why in my personal experience (and from what i&#8217;ve heard anecdotally from others), when you enroll at a school that promises a great placement program, they&#8217;re lying.  It&#8217;s often a marketing ploy to get you in the door.  You&#8217;ll certainly have to complete a placement to earn class marks, but you&#8217;ll have to hunt down the placement yourself.  When i was a student at Seneca College here in Ontario, the school had two or three placements in industry for their favourite sons, and the rest of us scrambled.  One girl got a job at her uncle&#8217;s trucking plant.  i found an internship on my own at the Durham Board of Education, working in the computer lab with students in junior kindergarten.  This was the final program requirement for 3D computer art and animation students.</p>
<p>The type of school you really want to attend is one that has high entrance standards, and that fails students early and often.  There are very few that do this, but i heard an apocryphal tale that Sheriden will refuse to graduate a 4th-year student with a weak portfolio/art thesis presentation.  (Note that Sheridan was on the panel&#8217;s very short list of prestigious schools.)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/panel2.jpg" alt="Fan Expo State of the Video Game Industry panel"></p>
<p>Ryan M covers his mouth in horror as Ryan C tells Lesley a particularly upsetting fart joke.
</p></div>
<p><b>Q:</b>How do you choose the right school?<br />
<b>A:</b>Most of the panelists were too political to answer frankly.  i don&#8217;t toe the same line, because i feel that many of the schools in this province &#8211; particularly the community colleges &#8211; are doing the industry and their customers a great disservice, and should be held accountable.  i warned against schools with very new programs (which is most of them), because they often work out the kinks at the expense of their initial student intakes.  i also took issue with schools whose teachers have very tenuous connections to industry.  i was speaking to a colleague of mine not long ago, who suggested that every two years, the colleges should kick their instructors back out into industry to ensure they&#8217;re keeping their skills up to date.</p>
<p>Ian mentioned that organizations like io in other countries have partnered with (bullied?) schools into an arrangement where the trade association has to approve its course offering in order for the school to earn a passing grade from industry. As a prospective student, you just look up which schools the association recommends, and apply there.  i like that idea, but i worry it&#8217;s prone to abuse in the name of politics and playing nice.</p>
<h2>Party On and Be Excellent to Each Other</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_08_30/billTed.jpg" alt="Bill &#038; Ted"></p>
</div>
<p>If there was one main takeaway from the conversation, it was to focus on personal excellence.  The very best stand out, while everyone else falls to the wayside, as in all things.  You wanna make games?  Then the barrier to entry is so low, as Jason said and as Ian reminded us, that you <em>should already be making games</em>.  Don&#8217;t wait on UbiSoft or some small indie shop to give you your big break.  There&#8217;s a golden opportunity for you right here, right now that didn&#8217;t exist when the rest of us were getting our start.</p>
<p>The panelists spoke about a number of groups, technologies and resources.  Here&#8217;s a non-exhaustive list:</p>
<p><b>Groups</b></p>
<ul>
<li><a href="http://handeyesociety.com/">Hand Eye Society</a> Where Toronto&#8217;s indie developers meet.
<li><a href="http://www.igda.org/toronto">IGDA Toronto Chapter</a> This group places more emphasis on professional development than the HES.
<li><a href="http://nomediakings.org/artsygames/">Artsy Games Incubator</a> Artists who want to make games, but have no programming ability, get together to &#8230; make games!  Closely tied to Jim Munroe&#8217;s efforts at the HES.
<li><a href="http://www.tojam.ca/home/default.asp">TOJam</a> The Toronto Indie Game Jam, an annual event where the city&#8217;s pros and hopefuls get together over one weekend to make games. A fantastic event.
<li><a href="http://www.flashinto.com/">FlashInTO</a> The Toronto Flash user group.
</ul>
<p><b>Technologies</b></p>
<ul>
<li><a href="http://unity3d.com/">Unity 3D</a> Create 3D video games in the browser, with a (comparatively) low learning curve.
<li><a href="http://www.adobe.com/products/flash/">Adobe Flash</a> A relatively inexpensive program for creating 2D and quasi-3D browser games.  Lots of books and tutorials &#8211; join our ranks of over two million developers!
<li><a href="http://www.yoyogames.com/gamemaker/">Game Maker</a> A free game creation tool, and the favourite of many indies.
<li><a href="http://scratch.mit.edu/">Scratch</a> An easy-to-grasp game creation tool from MIT
<li><a href="http://www.udk.com/">UDK</a> The consumer version of the Unreal Engine.  i don&#8217;t recommend this one because of its eventual high cost (despite an initially free download)
</ul>
<p><b>Resources</b></p>
<ul>
<li><b>Unity by Example</b>, a book written by me that is coming out very shortly.  It&#8217;s a great resource for new game developers that teaches you how to make small, simple games, and how to approach your game dev career so that you don&#8217;t give up on it. Send an email to info [the at symbol] untoldentertainment.com and i&#8217;ll send you a note once it&#8217;s available.
<li><a href="http://en.mochimedia.com/">MochiMedia</a>, <a href="http://www.kongregate.com/">Kongregate</a>, <a href="http://www.flashgamelicense.com/">FlashGameLicense</a>, <a href="http://www.heyzap.com/">HeyZap</a> Four places (of MANY) to distribute and monetize games you create with Flash.
<li><a href="http://www.wooglie.com/">Wooglie</a> A unity game portal.
<li><a href="http://www.tigsource.com/">TIGSource</a> The de facto site for indies.
<li><a href="http://www.untoldentertainment.com/blog/feature-articles/pimp-my-game/">Pimp My Game</a> Our own series on making money (or not) with Flash games. Includes tons of sites that spill the beans about the financials on their games.
</ul>
<p>Were you at the panel?  Do you have anything to add?  Was there anything you wanted to ask that you didn&#8217;t get a chance to ask?  Leave me a comment and we&#8217;ll have a great discussion. </p>
<p>Thanks to <a href="http://dendritejungle.livejournal.com/">dendritejungle</a> and <a href="http://jason.con.ca">Jason MacIsaac</a> for the pics!</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F08%2F30%2Ftoronto-fan-expo-2010-state-of-the-toronto-game-industry-panel%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F08%2F30%2Ftoronto-fan-expo-2010-state-of-the-toronto-game-industry-panel%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/08/30/toronto-fan-expo-2010-state-of-the-toronto-game-industry-panel/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2840&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/08/30/toronto-fan-expo-2010-state-of-the-toronto-game-industry-panel/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Cooking with Flash: Learning the Timeline</title>
		<link>http://www.untoldentertainment.com/blog/2010/06/08/cooking-with-flash-learning-the-timeline/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/06/08/cooking-with-flash-learning-the-timeline/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 20:00:23 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cooking With Flash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2602</guid>
		<description><![CDATA[Prerequisites: Basic Flash Project Setup Drawing with Strokes and Fills Groups and Layers Begin Flash wasn&#8217;t always this difficult to get your head around. Before it was hijacked by codemonkeys, the software was a very capable animation program. The focal point of Flash animation is the Timeline, and all the wonderful things it can do. [...]]]></description>
			<content:encoded><![CDATA[<p><b>Prerequisites:</b></p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/">Basic Flash Project Setup</a>
<li><a href="http://www.untoldentertainment.com/blog/2010/05/12/cooking-with-flash-drawing-with-strokes-and-fills/">Drawing with Strokes and Fills</a>
<li><a href="http://www.untoldentertainment.com/blog/2010/05/21/cooking-with-flash-groups-and-layers/">Groups and Layers</a>
</ul>
<h2>Begin</h2>
<p>Flash wasn&#8217;t always this difficult to get your head around.  Before it was hijacked by codemonkeys, the software was a very capable animation program.  The focal point of Flash animation is the Timeline, and all the wonderful things it can do.  This lesson is a primer on how to move around the timeline and to figure out how it works.  In a future lesson, we&#8217;ll delve into different animation styles you can pull off using the Timeline.</p>
<p>Start a project as described in Basic Flash Project Setup, or continue from an existing project.  Make sure that you can see the Timeline in your screen setup.  In the menus, click Window > Timeline.</p>
<h2>1. Time moves from left to right.</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/timeline.jpg" alt="Flash timeline"></p>
</div>
<p>This is an obvious point if you&#8217;ve used any other timeline-based software like Premiere, Audacity, or Director.  Those numbers stretching off into the distance are <em>frame numbers</em>.  A frame is a single picture in your movie.  Play the pictures one after another quickly enough, and our persistence of vision creates the illusion of motion.   </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/flipbook.jpg" alt="Flipbook"></p>
<p>Flipbooks use sequential images to trick the eye into seeing motion. The Flash Timeline is an elaborate flipbook.
</p></div>
<h2>2. FPS Determines how fast your frames play.</h2>
<p>Your default .fla file makes frames whizz by at 30 frames per second. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/fps.jpg" alt="Flash Properties frames per second setting"></p>
</div>
<p>To change the frame rate of your Flash movie, type a different number into the FPS: field in the Properties panel (Window > Properties). </p>
<p><b>note:</b> The Properties panel is context-sensitive, which means that it shows different options depending on what you&#8217;ve selected. To see the FPS setting, click on any blank area of the stage.</p>
<p>30 FPS is standard for most video.  Classical animators used to work at 24 frames per second for feature films, and 12 frames per second for television and lower-quality animation.  12 fps is sometimes called working &#8220;on twos&#8221;, because the camera man would photograph each drawing twice to bring it up to 24 fps.  The fewer the drawings you use in your animation, the choppier your animation will look.</p>
<h2>3. Understanding keyframes</h2>
<p>The word &#8220;keyframe&#8221; is inherited from animation. A common technique for animating a scene &#8211; especially involving a character &#8211; is to draw the <em>key frames</em> in the action.  If you&#8217;re animating a bouncing ball, you might have three key frames: the ball at the top of its drop, the ball at the bottom as it squishes against the ground, and the ball at the top again.  Keys are the most crucial drawings in the action.  A person should be able to completely understand what&#8217;s going on just by looking at the keys.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/keys.jpg" alt="Animation key frames"></p>
</div>
<p>Once you&#8217;ve drawn the keys &#8211; the most important drawings &#8211; you draw the in-betweens.  Without these drawings, we can&#8217;t create the illusion of motion.  They are the pictures that &#8220;move&#8221; us from one key to the next.</p>
<p>Computer animation packages like Flash enable us to set up key frames, and to draw our own in-betweens. Flash can also draw in-betweens <em>for</em> us using a process called <em>interpolation</em>.   We&#8217;ll look at interpolation, or <em>tweening</em>, in another tutorial.</p>
<h2>4. Understanding frame symbols</h2>
<p>There are important symbols that appear on frames.  Understanding them is the key to understanding the Timeline, like learning to read music.</p>
<ol>
<li>Blank keyframe
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/emptyKeyframe.jpg" alt="Flash blank keyframe"></p>
</div>
<p>An empty circle indicates a blank keyframe. There is nothing on the stage on this layer on this frame.  </p>
<li>Keyframe
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/keyframe.jpg" alt="Flash keyframe"></p>
</div>
<p>A black circle with a grey background indicates a filled keyframe.  There is something on the stage on this layer on this frame.</p>
<li>Empty frame
<p>A blank white frame means that our animation will play to at least this point.  The animation continues to play until it reaches the latest keyframe, blank keyframe, blank frame or filled frame in the Timeline. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/blankFrame.jpg" alt="Flash blank frame"></p>
<p>Even though the stage is empty, this animation will play past frame 30 because the blank frames stretch at least that far.
</p></div>
<li>Filled frame
<p>A frame with a grey background means that the contents of the preceding keyframe appear on stage to at least this point.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/frame.jpg" alt="Flash filled frame"></p>
<p>The contents of frame 1 stay on stage well past frame 30.
</p></div>
<li>Terminal frame
<p>This white rectangle marks the point after which the contents of the preceding keyframe stop appearing on-stage.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_06_08/terminalFrame.jpg" alt="Flash filled frame"></p>
<p>The contents of frame 1 persist on stage from frame 1 to frame 20.  After frame 20, they stop showing up.
</p></div>
</ol>
<h2>5. The function keys insert frames.</h2>
<p>The F5, F6 and F7 keyboard keys are crucial when using the Timeline.  Used on their own, they insert various frame types. Hold down the SHIFT key and press one of these function keys to delete that frame type.</p>
<p>F5 &#8211; Add a frame.  They will be either blank or filled depending on whether they&#8217;re preceded by a blank or filled keyframe.<br />
SHIFT+F5 &#8211; Delete a frame.</p>
<p>F6 &#8211; Add a keyframe.  <b>note:</b> If you add a keyframe to a blank range of frames, you&#8217;ll drop in a blank keyframe.<br />
SHIFT+F6 &#8211; Remove a keyframe.</p>
<p>F7 &#8211; Add a blank keyframe.<br />
SHIFT+F7 &#8211; Remove a blank keyframe.</p>
<p><b>Sample usage:</b> If you have something on stage, and you want it to disappear at frame 25, add a blank keyframe to frame 25.</p>
<p>You can click and drag to range-select a chunk of frames to delete them, or to convert them to empty or filled keyframes.</p>
<p><b>note:</b> If you insert frames, they don&#8217;t overwrite your existing frames. Rather, the end of your Timeline on that layer gets pushed out farther.</p>
<h2>6. The Playhead controls frames on all layers.</h2>
<p>If you want to add or remove different frame types through all layers of the timeline simultaneously, first click on the pink rectangular Playhead.   Then when you add or remove frames, they&#8217;ll be added to or removed from all layers at once.</p>
<h2>7. Scrub or play your animation. </h2>
<p>Click and hold the mouse button on a frame and move the mouse around to preview your animation.  This is called &#8220;timeline scrubbing&#8221;. </p>
<p>To scrub the Timeline without fear of moving your keyframes around, click and drag the pink Playhead back and forth.</p>
<p>To play your animation within the Flash IDE, press the ENTER key on your keyboard.</p>
<p>To compile your movie to a swf, hold CTRL and press ENTER (Command+Enter on the Mac).  Notice that Flash automatically loops when the Playhead reaches the end of the timeline.</p>
<p><b>note:</b> In order to drag your empty and filled keyframes around, first click on the keyframe to select it, <em>then</em> click and drag to move it around.</p>
<h2>Finish</h2>
<p>This basic Timeline lays the foundation for the actual animation exercises we&#8217;ll be doing.  We&#8217;ll learn how to do &#8220;straight-ahead&#8221; or &#8220;frame-by-frame&#8221; animation, as well as how to get Flash to draw the in-betweens for us.
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F06%2F08%2Fcooking-with-flash-learning-the-timeline%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F06%2F08%2Fcooking-with-flash-learning-the-timeline%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/06/08/cooking-with-flash-learning-the-timeline/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2602&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/06/08/cooking-with-flash-learning-the-timeline/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cooking with Flash: Drawing with Strokes and Fills</title>
		<link>http://www.untoldentertainment.com/blog/2010/05/12/cooking-with-flash-drawing-with-strokes-and-fills/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/05/12/cooking-with-flash-drawing-with-strokes-and-fills/#comments</comments>
		<pubDate>Wed, 12 May 2010 15:49:24 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cooking With Flash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2515</guid>
		<description><![CDATA[Prerequisites: Basic Flash Project Setup Begin Let&#8217;s learn to draw with Flash! Flash is not the most feature-rich vector drawing package available. During its development lifecycle, the creators of Flash listened more closely to programmers than artists. As a result, many new features for artists fell by the wayside, while Flash developed a (near) fully-featured [...]]]></description>
			<content:encoded><![CDATA[<p><b>Prerequisites:</b></p>
<ul>
<li><a href="http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/">Basic Flash Project Setup</a>
</ul>
<h2>Begin</h2>
<p>Let&#8217;s learn to draw with Flash! </p>
<p>Flash is not the most feature-rich vector drawing package available. During its development lifecycle, the creators of Flash listened more closely to programmers than artists. As a result, many new features for artists fell by the wayside, while Flash developed a (near) fully-featured programming language in its own right, ActionScript 3.0.  Meanwhile, other software developers came along and ate Flash&#8217;s lunch &#8211; most notably <a href="http://en.wikipedia.org/wiki/Toon_Boom_Animation">Toon Boom Animation</a> with its Harmony product, which is used in feature film production by Disney and other animation studios.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/harmony.png" alt="Toon Boom Harmony"></p>
<p>Because Toon Boom listened to animators while bulding the product, Harmony embarrasses Flash as an animation production tool.
</p></div>
<p>Still, Flash contains a great set of vector drawing tools, with some decent animation capabilities.  In this tutorial, we&#8217;ll cover the unique way in which Flash handles vector drawing.</p>
<h2>Vector vs. Raster</h2>
<p>Before we begin, we should just cover off what the word &#8220;vector&#8221; means as it pertains to drawing software.  Let&#8217;s take two images: a vector image on the left, and a raster image on the right:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/bunnies.jpg" alt="A vector and a raster bunny"></p>
</div>
<p>Now we&#8217;ll zoom into both images:</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/bunnies_zoomed.jpg" alt="A vector and a raster bunny zoomed"></p>
</div>
<p>Notice that the vector image remains smooth, while we can see the individual pixels (short for &#8220;picture elements&#8221;) that make up the raster image.</p>
<p>This happens is because the computer draws each image differently.  Raster drawing is like painting on a canvas, while vector drawing is like describing shapes with math.  The computer retains the <em>mathematical calculations</em> it needs to redraw a vector image at any size.  But when you blow up a raster image, there&#8217;s only <em>so much</em> picture information the computer knows about the image. It can try filling in the blanks, but the results are usually mediocre.</p>
<p>The other big difference between the two comes when you want to move elements around.  In a vector image, elements are separate, like fridge magnets.  You can move them around, and put them in front of or behind each other, and all is fine and dandy. But when you move a piece of a raster image, it&#8217;s like you&#8217;re taking a pair of scissors to a canvas and cutting a chunk out of it &#8211; you wind up with a gaping hole.  Modern raster programs often have a Layers feature that keeps elements separated, but this is just essentially like working with multiple flat images composited on top of each other. The problem remains.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/monaLisa.jpg" alt="Mona Lisa raster image"></p>
<p>I&#8217;m sorry, Sir &#8211; we&#8217;re going to have to ask you to kindly leave the Louvre.
</p></div>
<p>Some examples of raster image software include Photoshop, GIMP, and MS Paint.</p>
<p>Some examples of vector image software include Fireworks, Illustrator, Flash, and any 3D software (3D Studio Max, Maya, Blender, etc.)</p>
<p>Tricksy falseness occurs when you realize that many vector packages can <em>import</em> raster images.  Many times, i&#8217;ve requested a vector logo from a client so that i can blow it up to a certain size without it looking pixellated.  When i ask for the corporate logo &#8220;in Illustator&#8221;, i usually get an Illustrator file with an imorted raster image. Thees, of course, ees <em>boolchit</em>.  It makes more sense to ask for a <em>vector</em> image instead of an Illustrator file, but not everyone knows what exactly a vector image is.  Now <em>you</em> know!  Spread the word, and share this tutorial.</p>
<h2>1. Strokes vs. Fills</h2>
<p>In Flash, the things you draw are called <b>shapes</b>. The outline of a shape (the &#8220;stroke&#8221;) is separate from the colour inside a shape (the &#8220;fill&#8221;).  Witness:</p>
<ol>
<li>Open Flash.
<li>Click the Rectangle tool in the Tools palette, or press the R key on your keyboard. (If you can&#8217;t see the Tools palette, click Window > Tools in the menus, or hit CTRL/Command + F2 on your keyboard)
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/rectangleTool.jpg" alt="Flash Rectangle tool"></p>
</div>
<li>Click and drag the mouse on the Stage (the rectangular white area in the middle of the screen) to make a rectangle shape. By default, you should see a white rectangle with a black stroke.  You can change the stroke and fill colours before drawing by clicking the stroke and fill colour swatches in the Tools palette, and choosing different colours.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/colourSwatches.jpg" alt="Flash colour swatches"></p>
</div>
<li>Click the black Selection tool at the top of the Tools palette.
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/selectionTool.jpg" alt="Flash selection tool"></p>
</div>
<li>Click once inside the rectangle to select the white filled area.  It goes &#8220;fuzzy&#8221;, indicating that it&#8217;s selected.
<li>Click on any blank area on the Stage to deselect the fill.
<li>Double-click on the black stroke around the edge of the rectangle. The stroke goes fuzzy too, indicating that it&#8217;s selected. (you may notice that you can also single-click the stroke to select one of the four edges individually)
<li>Click and drag to move the stroke away from the fill, independently.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/selectedFill.jpg" alt="Flash selected fill"></p>
<p>A white rectangle on the stage with a selected fill &#8230;
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/selectedStroke.jpg" alt="Flash selected fill"></p>
<p>&#8230; and a selected stroke.
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/separated.jpg" alt="Separated stroke and fill"></p>
<p>You can pick up and move the stroke independently of the fill. (i&#8217;ve selected the white fill area so that you can see it against the white Stage)
</p></div>
<p>The stroke and fill are two separate things!  If at any time you want to select the fill and the stroke together, double-click the fill, and the stroke will be selected along with it.</p>
<h2>2. Strokes Cut Fills</h2>
<p>Strokes can behave like cut lines in sewing, or hot wires in clay modeling. They slice fills.  Let&#8217;s see that in action.</p>
<ol>
<li>Press CTRL/Command+A to select everything on the stage, and then press delete to get rid of your last shapes.
<li>Click the fill colour swatch in the Tools palette.  Click to select a non-white colour.  i like yellow, because it reminds me of delicious snow.
<li>Click the Rectangle tool, then click and drag to draw a rectangle on the Stage.
<li>Click the Selection tool (the black arrow)
<li>As before, double-click to select the stroke around the rectangle.
<li>Click and drag the stroke so that it intersects the fill.
<li>Click the part of the fill on the inside of the stroke. Now click the part of the fill on the outside of the stroke. Click and drag to move either of these fills to another part of the Stage.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/strokesCutFills.jpg" alt="Flash strokes cut fills"></p>
<p>Strokes cut fills.
</p></div>
<p>The stroke cut the fill in half, and made it into separate shapes.  For further exploration of this, try drawing a large rectangle, and draw wiggly strokes through it with the Pencil tool.  Note that your wiggly lines split the fills up into separate pieces too, because the Pencil tool creates fill-cutting strokes.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/pencilToolCut.jpg" alt="Flash strokes cut fills"></p>
<p>Here, i&#8217;ve used the Pencil tool to draw a wiggly stroke. It cuts the fill, so i can click and drag a wiggly-cut piece away as its own separate shape.
</p></div>
<h2>3. Working Without Strokes or Fills</h2>
<p>How do you get a rectangle without a stroke, or one without a fill?  In the colour palette fly-out, there is a small swatch with a red slash through it.  Use this to cancel the fill or stroke colour for your next shape.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/noStroke.jpg" alt="Flash no-colour button"></p>
<p>You can find the no-colour button in the top-right corner of the colour palette for both the stroke and fill swatches.
</p></div>
<h2>4. Same Colours Meld</h2>
<p>Two shapes of the same colour automatically fuse together.  Try it:</p>
<ol>
<li>Clear the stage of old artwork.  (CTRL/Command + A, Delete)
<li>Draw a red rectangle with no stroke (see above)
<li>Draw another red rectangle with no stroke overlapping the first.
<li>Click the Selection tool.
<li>Click on one of the two rectangles.  Both rectangles are selected.
</ol>
<p>There actually aren&#8217;t two rectangles any more &#8211; there&#8217;s only one.  Because they are the same colour, they melded together into the same shape.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/sameColoursUnite.jpg" alt="Flash same colours meld"></p>
<p>Two rectangles of the same colour meld together to form one shape.
</p></div>
<p>You can meld two shapes of the same colour even without drawing them on top of each other. Draw one red rectangle over here, then draw another one over there.  Using the Selection tool, drag one rectangle on top of the other. As long as the rectangle is selected, the two rectangles haven&#8217;t had colour sex yet &#8211; you can move the selected rectangle away without any fusion.  If instead you click the Stage to deselect the overlapping rectangle, then BOWM-CHIKKA!  What Flash has joined together, let no man put asunder.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/tooHot.jpg" alt="Flash same colours meld"></p>
<p>Order the VHS box set for $19.99.
</p></div>
<h2>5. Different Colours Cut</h2>
<p>As with strokes, two shapes of different colours will cut each other when they overlap.  Regard:</p>
<ol>
<li>Clear your old artwork (CTRL/Command + A, Delete)
<li>Draw a red rectangle on the Stage.
<li>Choose a new colour for the fill swatch.  i chose green, because it&#8217;s the colour i turned after i ate that delicious snow.
<li>Draw your differently-coloured rectangle on the Stage, overlapping the first rectangle.
<li>Click and drag either of the two rectangles away from each other.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/differentColoursCut.jpg" alt="Different colours cut"></p>
<p>Different colours cut each other, like the Jets and the Sharks.
</p></div>
<p>Two differently-coloured rectangles automatically slice each other, in what i can only assume is Flash&#8217;s way of warning us about racially-motivated violence.  Just as before, the two shapes don&#8217;t have to be drawn on top of each other for them to slice each other up.  Try drawing two shapes at opposite ends of the stage. Then drag one on top of the other.  Click on the Stage to deselect it &#8211; WHIPPOW!! That&#8217;s where the shanking happens.  Now drag one shape away from the other to view the carnage.</p>
<h2>6. Differently-Coloured Strokes are Distinct. Similarly-Coloured Strokes Become Fused.</h2>
<p>Finally, we&#8217;ll see how strokes behave with each other depending on their colours.</p>
<ol>
<li>Clear your old artwork (CTRL/Command + A, Delete)
<li>Choose the no-fill option for the stroke colour swatch.
<li>Choose a colour for your stroke.  i choose black, to reflect the rage and despair in my soul.
<li>Draw a rectangle on the Stage.
<li>Draw another black-stroked rectangle, overlapping the first one.
<li>Choose a different colour for your next stroke, like brown, which is the colour of chocolate when you poop it out.
<li>Draw another overlapping rectangle on the first one.
<li>Using the Selection tool, double-click the black stroke.  The two black rectangle strokes get highlighted together, indicating that they are one shape.
<li>Double-click the differently-coloured stroke. It highlights independently, indicating that it cannot be part of the black rectangles&#8217; undying love for each other.  Two days later, the brown rectangle was found at the bottom of Lake Billingsly with a cinder block tied around its ankles.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/strokeBoolean.jpg" alt="Flash stroke boolean"></p>
<p>The two black strokes band together, while the poor brown stroke is odd man out.
</p></div>
<p>Notice, also, that strokes cut other strokes.  Click on an individual line segment anywhere in your tri-rectangle shape.  Any of these pieces can be moved away from the larger shape as a separate piece.</p>
<h2>Finish</h2>
<p>i prize the Flash drawing tools for their speed.  You can draw all of the assets for your game right inside Flash, without having to buy other drawing programs to create your assets.  And this cutting/joining stuff speeds up my drawing immensely.  While it may seem unforgiving and awful at first, know that you can keep shapes away from each other by using layers and groups, which we&#8217;ll see in another tutorial.  But when it comes down to it, the process for creating similar joins and cuts in a competing program like Illustrator is slow as molasses and unwieldy.  The automatic cuts and joins in Flash, not to mention the stroke and point manipulation, are blazingly fast compared to Illustrator&#8217;s compound paths palette, and its finicky bezier handle-pulling.  Once i adopted the drawing tools in Flash, i wondered how i ever got anything done in Illustrator.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_07/illustrator.jpg" alt="Illustrator sucks for drawing"></p>
<p>Each of those bezier handles and their control points are 4 pixels square. Heck of a job, boys.  Heck of a job.
</p></div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F05%2F12%2Fcooking-with-flash-drawing-with-strokes-and-fills%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F05%2F12%2Fcooking-with-flash-drawing-with-strokes-and-fills%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/05/12/cooking-with-flash-drawing-with-strokes-and-fills/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2515&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/05/12/cooking-with-flash-drawing-with-strokes-and-fills/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cooking With Flash: Basic Flash Project Setup</title>
		<link>http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/#comments</comments>
		<pubDate>Thu, 06 May 2010 18:36:44 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Cooking With Flash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2504</guid>
		<description><![CDATA[Prerequisites: none. Begin So you want to start creating games with Adobe Flash? Here&#8217;s the very first step. You&#8217;ll need two pieces of software: Adobe Flash, and a program to in which to write your code. (Code is a list of instructions you give to the computer to make it bend to your steely will.) [...]]]></description>
			<content:encoded><![CDATA[<p><b>Prerequisites:</b></p>
<ul>
<li>none.
</ul>
<h2>Begin</h2>
<p>So you want to start creating games with Adobe Flash?  Here&#8217;s the very first step.</p>
<p>You&#8217;ll need two pieces of software: Adobe Flash, and a program to in which to write your code.  (Code is a list of instructions you give to the computer to make it bend to your steely will.)  You can write your code inside the Flash program, but Flash is always playing catch-up with the great features available in other programs that make coding easier.  And i like easy.</p>
<h2>1. Download the Software</h2>
<p>You can download a number of programs to help you code.  The one we recommend (and use here at Untold Entertainment to create all our games) is called FlashDevelop.  It&#8217;s free, but if you like it, consider tossing a few clams to the creators.</p>
<ul>
<li><a href="http://www.adobe.com/products/flash/">Download a free 30-day trial of Adobe Flash</a>
<li><a href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page">Download your free copy of FlashDevelop</a> (PC-only)
</ul>
<p>note: other popular programs that professionals use to create their code include <a href="http://www.fdt.powerflasher.com/developer-tools/fdt-3/">FDT</a>, <a href="http://www.adobe.com/products/flashbuilder/">Flash Builder</a> (formerly known as Flex Builder), and even a fancy text editor like <a href="http://notepad-plus.sourceforge.net/uk/download.php">Notepad++</a>.  (i&#8217;m told that if you use a Mac, you&#8217;re iShitOutOfLuck on this front, but perhaps the commenters can recommend something?)</p>
<p>Once you&#8217;re finished downloading the two pieces of software you need, install them into the default directories, and we&#8217;ll get started setting up a project.</p>
<h2>What <em>is</em> Flash?</h2>
<p>The term &#8220;Flash&#8221; is confusing.  You may have heard that some online video &#8220;<em>is</em> Flash&#8221;, that some games you play in the browser &#8220;<em>are</em> Flash&#8221;, that some websites &#8220;<em>use</em> Flash&#8221;, and more recently that Flash <em>runs</em> or <em>doesn&#8217;t run</em> on this device or that device.  The word &#8220;Flash&#8221; is used interchangeably for both the authoring tool, the content that you create with it, and the plugin that displays that content to the end user.</p>
<p>The Adobe Flash software is also called an authoring <em>tool</em>, like a paintbrush or a table saw.  With it, you produce Flash content (games, video players, websites, etc), which a person usually views in a web browser using a plugin called the Flash <em>Player</em>.  Most often, when someone says you need to &#8220;download Flash&#8221;, he means you need to download the Flash Player <em>plugin</em> so that you can view Flash <em>content</em> that was created with the Flash <em>tool</em>.   What you&#8217;re downloading in the link above is the tool, which is sometimes called the Flash IDE (Integrated Development Environment).  i prefer &#8220;tool&#8221;, because it&#8217;s only one syllable, and &#8220;eye dee yee&#8221; is not kind to the ear.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/manyUsesOfFlash.jpg" alt="The Many Uses of the Term 'Flash'"></p>
<p>The term &#8220;Flash&#8221; has multiple uses.
</p></div>
<h2>2. Create and Save a New Actionscript 3 .fla File</h2>
<p>When you open the Flash authoring tool for the first time, you&#8217;ll likely see a splash screen.  To create a new file, etiher click &#8220;Create New Flash File (Actionscript 3.0)&#8221;, or go to File > New and choose Flash File (Actionscript 3.0) from the list, and click OK.</p>
<p>Your Flash file opens up and is displayed in all its glory &#8211; tons of interesting buttons and panels all over the screen.  Don&#8217;t be intimidated. We&#8217;ll explore them in future lessons.</p>
<p>Click File>Save As in the menus.  Flash files have the extension .fla.  Change the name of your Flash working file to myFirstGame.fla (or whatever you like), and save it to a folder somewhere on your computer.  Remember where you saved it!  i recommend against saving it to the desktop &#8211; if you want it there, first create a folder on the desktop called MyFirstGame, and save your .fla file in there.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/flashIDE.jpg" alt="Adobe Flash IDE"></p>
<p>Look at all this great STUFF to mess around with!  (note: Flash supports all kinds of different layouts &#8211; you may see something different on your screen depending on the version and layout you&#8217;re using)
</p></div>
<h2>3. Create a New FlashDevelop Project</h2>
<ol>
<li>Open FlashDevelop.
<li>In the menus, go to Project > New Project.
<li>Choose a name for your project in the Name field. (You can call it MyFirstGame.  Seems logical.)
<li>Use the Browse button to point to the MyFirstGame folder you created, where saved your .fla file in the last step.
<li>Click OK.
<li>If you get a message saying &#8220;The directory is not empty &#8230;&#8221;, click OK to confirm.
<li>If FlashDevelop asks you the Author name, type your own name or a suitable pseudonym, like &#8220;Cap&#8217;n CrackyPants&#8221;.  All of the code you write will be signed with this name.
<li>Click OK.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/saveFlashDevelopProject.jpg" alt="Creating a new project in FlashDevelop"></p>
<p>Creating a new project in FlashDevelop
</p></div>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/flashDevelopAuthor.jpg" alt="FlashDevelop author prompt"></p>
<p>Señor Taco-Taker is like the Mexican Hamburglar
</p></div>
<p>When you&#8217;re finished, check out the Project Panel, at the right side of the screen. (If you can&#8217;t see it, click View > Project Manager in the menus.)  You&#8217;ll see your Project name, MyFirstGame.  Then you&#8217;ll see the .fla file you created in Flash, called myFirstGame.fla.  All of the code files you write to make your game will be listed here, along with any other files you place in the MyFirstGame folder.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/flashDevelopProjectPanel.jpg" alt="FlashDevelop project panel"></p>
<p>FlashDevelop Project panel
</p></div>
<p>Behind the scenes, FlashDevelop creates an .as3proj file in the folder, which is a metadata file that keeps track of what goes into the folder.  Once you create your Project file, you never have to save it like you would most other files &#8211; you can just open and close different Project files, and they&#8217;ll list the stuff that&#8217;s in the folder with them.</p>
<h2>4. Link FlashDevelop to Flash</h2>
<p>The last thing to do is to make FlashDevelop aware of the Flash authoring tool so that the two can play nicely together.  </p>
<ol>
<li>In the menus, click Tools>Program Settings or press F10.
<li>Click ASCompletion in the sidebar list.
<li>Click in the field labeled &#8220;Path to Flash IDE&#8221;, and navigate to wherever you installed the Flash tool on your computer.  On my Windows system, it&#8217;s here:
<p>C:\Program Files\Adobe\Adobe Flash CS4</p>
<li>Click the Close button.
</ol>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2010_05_06/flashDevelopSettings.jpg" alt="FlashDevelop Settings"></p>
<p>FlashDevelop Settings
</p></div>
<h2>Finish</h2>
<p>That&#8217;s it &#8211; you&#8217;re done!  Now you&#8217;re ready to create Flash content using the one-two punch combo of Flash and FlashDevelop.</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F05%2F06%2Fcooking-with-flash-basic-flash-project-setup%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F05%2F06%2Fcooking-with-flash-basic-flash-project-setup%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2504&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/05/06/cooking-with-flash-basic-flash-project-setup/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Tutorial: Clickify Your Twitter Feed in Flash</title>
		<link>http://www.untoldentertainment.com/blog/2010/02/24/tutorial-clickify-your-twitter-feed-in-flash/</link>
		<comments>http://www.untoldentertainment.com/blog/2010/02/24/tutorial-clickify-your-twitter-feed-in-flash/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 13:44:03 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=2230</guid>
		<description><![CDATA[&#8220;Fwitter&#8221;. Deal with it. Our Pull Twitter Updates Into Flash tutorials (Part 1 and Part 2) continue to be popular! A few folks were asking how i had taken my Twitter feed and rigged it so that people&#8217;s Twitter names and links were clickable. i promised to write tutorials on demand, so here we go. [...]]]></description>
			<content:encoded><![CDATA[<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_04_02/fwitter.jpg" alt="Fwitter">
</p>
<p>&#8220;Fwitter&#8221;.  Deal with it.
</p></div>
<p>Our <b>Pull Twitter Updates Into Flash</b> tutorials (<a href="http://www.untoldentertainment.com/blog/2009/04/02/tutorial-pull-twitter-updates-into-flash/">Part 1</a> and <a href="http://www.untoldentertainment.com/blog/2009/05/14/tutorial-twitter-updates-in-flash-part-2/">Part 2</a>) continue to be popular! A few folks were asking how i had taken my Twitter feed and rigged it so that people&#8217;s Twitter names and links were clickable.  i promised to write tutorials on demand, so here we go.</p>
<h2>Clickify Your Twitter Feed in Flash</h2>
<p>Here&#8217;s the process in pseudo-code:</p>
<ol>
<li>Take the chunk of text and split it up into individual words
<li>With each word, figure out if it starts with &#8220;@&#8221; or &#8220;http:&#8221;
<li>If it does, wrap it in html tags
<li>Re-assemble the string
<li>Set the re-constituted string as your dynamic text field&#8217;s htmlText property
</ol>
<p>So, let&#8217;s start with a simple chunk of Tweet text:</p>
<p>&#8220;Hey everyone &#8211; @untoldent&#8217;s blog is INCREDIBLE!  http://bit.ly/cXX06r&#8221;</p>
<blockquote><p>
Note: this is just a tweet i pulled at random from the Twittersphere.  It could have been anything.  But my blog is usually a trending topic at any given time of the day.</p></blockquote>
<p>We&#8217;ve got two things we want to make clickable: <a href="http://www.twitter.com/untoldent">@untoldent</a>, which should link to untoldent&#8217;s Twitter user page, and <a href="http://bit.ly/cXX06r">http://bit.ly/cXX06r</a>, which should take us to that webpage.</p>
<h2>Splitting the String</h2>
<p>The String class has a built-in method called split.  It takes an argument that lets us carve a string up, and the resulting fragments are put into an array.</p>
<p>So, for example, if we have a comma-delimited string:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> fraggles:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Gobo,Mokey,Wimbley,Boober,Red&quot;</span>;</pre></div></div>

<p>we can split it using the comma as a separator.  The resulting fragments are returned as an array.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> fraggles:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Gobo,Mokey,Wimbley,Boober,Red&quot;</span>;
<span style="color: #000000; font-weight: bold;">var</span> aFraggles:<span style="color: #0066CC;">Array</span> = fraggles.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// use the comma to split up the string</span>
&nbsp;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>aFraggles.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// 5</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>aFraggles<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Wimbley</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>aFraggles<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Red</span></pre></div></div>

<p>So in the case of our Twitter string, we want to split it up into individual words. The thing that separates one word from another is the space character. So let&#8217;s use space as an argument to split up that string:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> aWords:<span style="color: #0066CC;">Array</span> = twitterString.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// use the space character to split up the string</span></pre></div></div>

<blockquote><p>Note: the split method is slow, so use it sparingly.  There&#8217;s not a lot going on in our Twitter reader, so we can get away with it.</p></blockquote>
<p>Now let&#8217;s loop through each element in the aWords array &#8211; each word in the Twitter post &#8211; and determine if it&#8217;s a Twitter username (which starts with &#8220;@&#8221;), or a URL (which starts with &#8220;http:&#8221;).  We&#8217;ll create an empty string to hold our final output, and run each word through a separate method.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> finalString:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>; <span style="color: #808080; font-style: italic;">// Create a new string to hold our final output</span>
<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span> = aWords.<span style="color: #0066CC;">length</span>; <span style="color: #808080; font-style: italic;">// store the length of the aWords array to speed up our loop</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Loop through all of the words in our tweet:</span>
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> word:<span style="color: #0066CC;">String</span> = aWords<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// Store an individual word in a variable</span>
    finalString += <span style="color: #ff0000;">&quot; &quot;</span> + checkWord<span style="color: #66cc66;">&#40;</span>word<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Run the word through a checkWord method, and tack the </span>
    <span style="color: #808080; font-style: italic;">// return value onto the end of our finalString (along with a space character, to space the words out)</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<blockquote><p>Note: We&#8217;re storing the length of aWords in a variable, instead of saying i<aWords.length.  This is because the Flash Player has to do more work to look up the length property of aWords every single time we loop.  You can speed up your loops a tiny bit by using this trick. </p></blockquote>
<p>Obviously, what&#8217;s missing is the all-important checkWord() method.  Let&#8217;s build that next.</p>
<h2>The checkWord() Method</h2>
<p>Our checkWord() method is going to do this, in pseudo-code:</p>
<ol>
<li>Accept a word
<li>If the word starts with &#8220;@&#8221; or &#8220;http:&#8221;, wrap it in href tags and return the string
<li>Otherwise, just return exactly what was passed in
</ol>
<p>To check if a string contains a certain other string, use the String.indexOf() method.  indexOf() will return the place in the string where the other string first appears.</p>
<p>For example, let&#8217;s find the indexOf the capital letter &#8220;W&#8221; in the string &#8220;NSFW&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;NSFW&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>str.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;W&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 3</span></pre></div></div>

<p>The answer is 3, because &#8220;W&#8221; is at index 3 in the string.  (Remember that strings and arrays are 0-based &#8211; the first element is at index 0, the second element is at index 1, and so on.)</p>
<p>If the thing you&#8217;re looking for can&#8217;t be found anywhere in the string, the indexOf() method will return an index of -1:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;NSFW&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>str.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;pictures of adorable kittens&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// -1</span></pre></div></div>

<h2>Substring</h2>
<p>The last thing you need to know how to do is to grab just a piece of a string.  This is because the twitter name comes through with an @ symbol at the front, for example @untoldent.  But we need to link to http://www.twitter.com/untoldent.  Notice there&#8217;s no &#8220;@&#8221; in that URL.</p>
<p>We need to extract just the username from the string, without the &#8220;@&#8221;.  We can use the String.substr (substring) method to do that.</p>
<p>The way String.substr() works is that you pass it a start point and an end point, and it rips that section out of the string and returns it.</p>
<p>So, check it out:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;manboobs&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>str.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// boobs</span></pre></div></div>

<p>The letter at index 3 of &#8220;manboobs&#8221; is &#8220;b&#8221;.  (Remember &#8211; we start counting at zero.)  We rip the section out up to index 7, which is that last letter, &#8220;s&#8221;.  So what&#8217;s returned are the letters from index 3 to index 7 &#8211; &#8220;boobs&#8221;.</p>
<p>If you want to rip out a chunk of your string from a certain index point to the last letter in the string, you can use the String.length property.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;manboobs&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>str.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>,str.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// boobs</span></pre></div></div>

<p>If you&#8217;re on high alert and paying really close attention, you&#8217;ll notice that str.length takes us one index point past the end of our string.  (&#8220;manboobs&#8221; is 8 characters long, and there IS no letter at index 8.)  Flash just ignores us if we try to grab more of the string than actually exists.  So technically, this is also valid:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;manboobs&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>str.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">5000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// boobs</span></pre></div></div>

<p>Armed with this knowledge, we can build our checkWord() method.</p>
<h2>Let&#8217;s Do This Thing</h2>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> checkWord<span style="color: #66cc66;">&#40;</span>word:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
   <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>word.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http:&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
         <span style="color: #808080; font-style: italic;">// This word starts with &quot;http:&quot; at index 0 (the beginning of the word)</span>
&nbsp;
         <span style="color: #808080; font-style: italic;">// Wrap it in html href (anchor) tags:</span>
         <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&lt;a href='&quot;</span> + word + <span style="color: #ff0000;">&quot;'&gt;&quot;</span> + word + <span style="color: #ff0000;">&quot;&lt;/a&gt;&quot;</span>;
   <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>word.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;@&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
         <span style="color: #808080; font-style: italic;">// This word starts with &quot;@&quot; at index 0 (the beginning of the word)</span>
&nbsp;
         <span style="color: #000000; font-weight: bold;">var</span> justTheName:<span style="color: #0066CC;">String</span> = word.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, word.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Remove the &quot;@&quot; from the username</span>
         <span style="color: #808080; font-style: italic;">// We do this because we need to link to http://www.twitter.com/untoldent (for example),</span>
         <span style="color: #808080; font-style: italic;">// not http://www.twitter.com/@untoldent</span>
&nbsp;
         <span style="color: #808080; font-style: italic;">// Wrap it in html href (anchor) tags:</span>
         <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&lt;a href='http://www.twitter.com/&quot;</span> + justTheName + <span style="color: #ff0000;">&quot;'&gt;&quot;</span> + word + <span style="color: #ff0000;">&quot;&lt;/a&gt;&quot;</span>;
   <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// There's nothing special about this word.  Return it as-is.</span>
        <span style="color: #b1b100;">return</span> word;
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<blockquote><p>Note: Did you notice the use of single quotation marks and double quotation marks?  You need to wrap you url in quotes, but since we&#8217;re already using double-quotation marks around our string, we need to use single-quotation marks to wrap the url, or they&#8217;ll interrupt our string definition and screw things up.</p></blockquote>
<h2>The Money Shot</h2>
<p>So far, we&#8217;ve turned this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #ff0000;">&quot;Hey everyone - @untoldent's blog is INCREDIBLE!  http://bit.ly/cXX06r&quot;</span></pre></div></div>

<p>into this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #ff0000;">&quot;Hey everyone - &lt;a href='http://www.twitter.com/untoldent'&gt;@untoldent's&lt;/a&gt; blog is INCREDIBLE!  &lt;a href=''&gt;http://bit.ly/cXX06r&lt;/a&gt;&quot;</span></pre></div></div>

<p>The very last step is to use the htmlText property of your dynamic text box and stuff it with that fancy new string.  Assuming you have a dynamic text box called twitterTxt, do this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">twitterTxt.<span style="color: #0066CC;">htmlText</span> = finalString;</pre></div></div>

<p>You&#8217;ll now have clickable links inside your text field.</p>
<h2>Extra Credit</h2>
<p>If you&#8217;re super-astute, you&#8217;ve noticed that this code won&#8217;t actually work!  That&#8217;s because the Twitter string says &#8220;@untoldent&#8217;s&#8221;, not &#8220;@untoldent&#8221;.  The apostrophe-s is going to screw your code up, because you&#8217;ll be linking to http://www.twitter.com/untoldent&#8217;s, which is not a valid URL.</p>
<p>Using what you&#8217;ve learned in this tutorial, can you augment your checkWord() method to detect a &#8220;&#8216;s&#8221; at the end of a Twitter user name and rip it out?</p>
<h2>Further Reading</h2>
<p>i hope this tutorial was informative and helpful!  For more Actionscript and Flash tutorials, thrill to our <a href="http://www.untoldentertainment.com/blog/flash-and-actionscript-911/">Flash and Actionscript  911</a> book.</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F02%2F24%2Ftutorial-clickify-your-twitter-feed-in-flash%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2010%2F02%2F24%2Ftutorial-clickify-your-twitter-feed-in-flash%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2010/02/24/tutorial-clickify-your-twitter-feed-in-flash/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=2230&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2010/02/24/tutorial-clickify-your-twitter-feed-in-flash/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>The 8 Types of Items in Multiplayer Games</title>
		<link>http://www.untoldentertainment.com/blog/2009/09/29/the-8-types-of-items-in-multiplayer-games/</link>
		<comments>http://www.untoldentertainment.com/blog/2009/09/29/the-8-types-of-items-in-multiplayer-games/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 14:06:48 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bidness]]></category>
		<category><![CDATA[microtransactions]]></category>
		<category><![CDATA[Morality]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=1844</guid>
		<description><![CDATA[You may or may not know the name &#8220;Nexon&#8221;, but you&#8217;ve most likely heard of their games. The Korean company has produced the industry-leading titles Maple Story and Kart Rider, to name but two. And although they may not have invented virtual item sales through microtransaction as they sometimes claim, my hat&#8217;s off to them [...]]]></description>
			<content:encoded><![CDATA[<p>You may or may not know the name &#8220;Nexon&#8221;, but you&#8217;ve most likely heard of their games.  The Korean company has produced the industry-leading titles <b>Maple Story</b> and <b>Kart Rider</b>, to name but two.  And although they may not have <em>invented</em> virtual item sales through microtransaction as they sometimes claim, my hat&#8217;s off to them for showing the world that you can make a tidy sum from them.</p>
<div class="invisible">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/barnum.jpg" alt="The Art of Money Getting">
</div>
<p><a href="http://www.gamasutra.com/php-bin/news_index.php?story=25347">Nexon&#8217;s Min Kim was recently interviewed by Gamasutra</a> about the company&#8217;s upcoming virtual world <b>Block Party</b>. During the interview, Kim rattled off a list of the eight types of items you can sell in an online game.  </p>
<blockquote><p>When it comes to items, they can serve eight purposes, says Kim: function, envy/prestige, recognition, collecting, rarity/scarcity, competition, friendship, peer pressure. These are the keywords, he said several times, that you should be thinking about when designing your items to sell. </p></blockquote>
<p>With the likes of MochiMedia, GamerSafe and HeyZap offering Flash microtransactions, i thought it would be worthwhile to explore Kim&#8217;s list, and to provide examples to flesh out his examples.  Some of these item classifications bleed into others. Most of them need to hook into some sort of multiplayer game, because they&#8217;re driven by social interactions.  But there are ways to structure your game to leverage feelings of envy and aspiration that don&#8217;t require a live multiplayer server, which i&#8217;ll explain in this article.</p>
<h2>1. Function</h2>
<p>The first item type is one that affects gameplay, like the downloadable tracks in <b>Rock Band 2</b>.  Other, more generic examples are things like guns that provide extra firepower, and winged mounts that let you fly clear across a virtual world.  Often, these items have the most perceived value to a player because they actually <em>do</em> something.  Occasionally, they&#8217;ll even give a player an advantage over other players during gameplay.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/rockBandMusicStore.jpg" alt="Rock Band Music Store"></p>
<p>i dropped twenty bucks in the RB2 store this past weekend, and only played one new song.  Don&#8217;t judge me.
</p></div>
<p>The danger is that by selling functional items, you risk alienating your player base, creating a class system of haves and have-nots.  When poorly designed, functional items can actually exclude players from playing together; in the case of <b>Rock Band</b>, all four band members have own a downloadable track in order to play through that song together. It&#8217;s not long before a group of online strangers have to default to the songs that shipped with the disc, because none of them own identical set lists.  Electronic Arts faced a <a href="http://kotaku.com/370694/ea-charging-for-bad-company-weapons">lot of flack</a> when players learned they would be charging extra money for in-game weapons in <b>Battlefield: Bad Company</b> that many people thought should have been included with the experience.</p>
<h2>2. Envy/Prestige</h2>
<p>Virtual clothing fits nicely into this category.  In a multiplayer game, everyone wants to stand out.  We can all recall the pain of spending half an hour tooling up a character for a virtual world, only to jump into that world to find that half the game&#8217;s population chose the same hat, boots and skin tone.  Finding your twin online isn&#8217;t quite as annoying as wearing the same dress as another girl to prom, but it&#8217;s up there.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/imvu.jpg" alt="IMVU"></p>
<p>IMVU fulfills every little girl&#8217;s dream of growing up to be slutty.
</p></div>
<p>Some games are even designed so that all of the free players (or &#8220;hobos&#8221;, as i like to call them) look just similar enough as to annoy the player.  A quick hit with the credit card is enough to straighten that out &#8211; one dollar buys you a new wardrobe item that no one else has.  That is, until <em>everyone else</em> spends a dollar to have it, in which case you need to keep ponying up the real-world cash to stay ahead of the fashion curve.  </p>
<p>The Xbox Live service recently added an Avatar Marketplace that consists solely of Envy/Prestige items.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/avatar.jpg" alt="Xbox Live Avatar"></p>
<p>i spent five bucks to watch a fake person having fun?
</p></div>
<h2>3. Recognition</h2>
<p>Recognition items that are based on player achievement, like trophies, banners and crests, are difficult to sell.  These are most often freebies that a player unlocks by accomplishing something in the game.  One way that i suppose you could monetize this type of item is to enable the player to pay to turn a free achievement into a concrete item.</p>
<p>Let&#8217;s say, for example, that they player can buy a statue of himself to put in the town square, but ONLY if he kisses seventeen muskrats.  The player goes out and accomplishes this amazing feat, but has no real way to show it off &#8211; no one is going to go digging through the player&#8217;s mission log to uncover that particular accomplishment.  So the player pays $23.95 real-world dollars to convert his achievement into the statue to brag about his prowess with muskrats.</p>
<p>Another option is to charge players to unlock badges, trophies and achievements that other players come by honestly.  This kind of thing can go on in an after-market area &#8211; for example, while researching this article, i found a site that purports to sell you Pogo Club badges for $5 apiece. </p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/pogo.jpg" alt="Pogo Badges"></p>
<p>We don&#8217;t need no stinking &#8230; oh, forget it.
</p></div>
<p>Of course, players who spend a million hours mastering a game to unlock the Magic Whizzwang cry foul if you start selling Magic Whizzwangs to players with more dollars than time.  There are a few strategies you can adopt here:</p>
<ol>
<li>Do it anyway, and cry yourself to sleep on a bed of money.
<li>Run the after-market site yourself, but don&#8217;t put any corporate branding on it, so that it <em>looks</em> like some shady fly-by-night site is selling badges, but you get all the profit
<li>Don&#8217;t do it, and risk losing out on a potentially major source of revenue.
</ol>
<p>There&#8217;s not a lot of difference between selling achievements and selling powerful in-game weapons.  In both cases, you&#8217;re monetizing &#8220;time-poor, money-rich&#8221; players over &#8220;time-rich, money-poor&#8221; (AKA hobo) players.  The difference is purely psychological: we think of awards as something to be <em>earned</em>, not bought.  Of course, graduate to the Real World and you&#8217;ll find that most things in this life are earned with money, <a href="http://www.untoldentertainment.com/blog/2008/04/08/canadian-new-media-awards/">awards included</a>.</p>
<h2>4. Collecting</h2>
<p>This is one of my absolute favourite item types to design.  When i was working on <b><a href="http://www.ytv.com/sitekick">The Sitekick Proejct</a></b> for Corus Entertainment, i designed a number of often complex item collections, where certain items had to be combined like <em>Voltron</em> to unlock other items.  i didn&#8217;t quite reach that Mecca where i had kids combining their Voltron uber-items to unlock Super Mega Ultra items, but i can see that&#8217;s where my career would have gone if i had stayed. :)</p>
<div class="displayed">
<p><a href="http://www.ytv.com/sitekick"><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/sitekick.jpg" alt="Sitekick"></a></p>
<p>Confession: i friggin&#8217; LOVE Sitekick.
</p></div>
<p>Of course, the natural progression for <b>The Sitekick Project</b> or any game like it, with its big empty <b>Pokemon</b>-inspired list and it&#8217;s 1000 some-odd items is to charge players for items so that they can fill in gaps in their collections.  While it&#8217;s a reasonably compelling prospect for an adult, you have to understand that maintaining complex collections is a psychological attribute of your people, and completing that sticker album or plastic pony set becomes absolutely <em>crucial</em>.  It might be worth a few bucks to mom and dad to stop junior from having the DTs and just buy one or two missing items.</p>
<h2>5. Rarity/Scarcity</h2>
<p><b>The Sitekick Project</b> also had its share of rare items, but of course it picked up its cues from other games &#8211; most notably CCGs, or Collectible Card Games.  And CCGs owe it all to baseball cards.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/babeRuth.jpg" alt="Babe Ruth rookie card"></p>
<p>Babe Ruth&#8217;s rookie card. My gut tells me this has appreciated in value.
</p></div>
<p>The very best way to monetize rare items, incidentally, is to follow the baseball card model: items are sold in packs. Some items are rare.  The player must continue to purchase packs filled with mostly mundane items and &#8220;doubles&#8221; in the hopes of stumbling upon a rare item.  You can even produce rareities in tiers: you can go from &#8220;rare&#8221; at .01% probability to &#8220;legendary&#8221; at 0.001% probability.  Rare items are usually shiny.</p>
<p>Depending on your scruples as a designer, you can also charge your players a large fee to flat-out <em>buy</em> a rare item.  Just make sure the price is high enough to deter most players, who will likely end up spending more than the cost of the buy-out price fishing for rare items.  This is the crane game principle that leads you to spend $35 trying to snag a $2 stuffed animal out of the machine, when the same amount of money could have gone towards a perfectly nice Gund bear at the Hallmark store down the street.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/craneGame.jpg" alt="Crane Game"></p>
<p>Just say NO to crack cocaine, and these things.
</p></div>
<p>Another way to sell scarcity is to release a series of items and to arbitrarily limit their quantities. Of course, since the items are digital, scarcity is entirely artificial. Imposing an item quantity on them or selling an item for a limited time only is a great way to see completist players snapping stuff up like it&#8217;s an End of the World Sale.  And once a player buys a limited item and the sale expires, it becomes both a Rare and Prestige/Envy item in one fell swoop. </p>
<h2>6. Competition</h2>
<p>i had trouble interpreting this one, and discerning it from Prestige/Envy items.  There are a few ways i can think of to charge for competition:</p>
<ol>
<li>Sell tickets or entry fees to competetive events
<li>Build in a competetive aspect and charge players for the item with which they compete (a friend of mine bought a lot of Xbox games so that he could get a higher GamerScore than me. The Achievements are free [with purchase of game].  The <em>purchase of game</em> isn&#8217;t.)
<li>Sell the game itself and let players be competetive on their own. For example, you can see an air hockey table as a furniture item for a player to store in his room.  The player can challenge friends to come to his house and beat him at air hockey.  You can even build in a &#8220;home advantage&#8221; to an air hockey board that a player owns &#8211; perhaps the owner of the table always gets to go first?
</ol>
<h2>7. Friendship</h2>
<p>Korean game <b>Cyworld</b> popularized virtual gift-giving, and went so far as to make those virtual gifts <em>expire</em>, which blew my mind.  This was years before North American designers were even thinking about virtual item sales, and the Koreans were already pioneering a virtual sofa that you could buy with real money and give to a friend that would vanish in a puff of smoke after two weeks.  It boggles my mind.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/facebookGifts.jpg" alt="Facebook Gifts Landfill"></p>
<p>A brilliant bit by artist Arend deGruyter-Helfer &#8211; a Facebook Gifts landfill.
</p></div>
<h2>8. Peer Pressure</h2>
<p>Again, this is a subtle thing to distinguish from a Prestige/Envy item.  i think the difference is that a Prestige/Envy item is something that one person has that you want.  A Peer Pressure item is something that EVERYBODY has.  You want it not because it&#8217;s a particularly attractive item, but because you don&#8217;t want to feel left out.</p>
<p>Here&#8217;s how i see this working:  throw a toga party in your virtual world. Hype it HUGE.  Have everyone mail away (in-game) for a toga, and cut off mail-in toga orders at a certain point.  Then just grind away on the hype machine for a week, while the players can&#8217;t order a toga. On the day of the party, everyone who sent away for one receives a free toga via in-game mail. You can also find other ways to give away togas for free on the day. Make sure it&#8217;s well known that EVERYBODY must have a toga to properly party.</p>
<p>When over half of your players have a toga, and the other half do not, make togas available as an impulse item for x real-world dollars (or cents).  Then, sit back and watch people snap up those togas.</p>
<p>This is a good way to avoid pissing off your players: you gave them <em>every opportunity</em> to get a toga for free.  The players who have to buy togas have only themselves to blame.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/freaks.jpg" alt="Freaks"></p>
<p>One of us &#8230; one of us &#8230; one of us &#8230;
</p></div>
<p>Here are a few additional categories of virtual item types that i&#8217;d like to add to Min Kim&#8217;s list:</p>
<h2>Sustainability Items</h2>
<p>These are items or services that constantly suck players&#8217; resources to keep them playing.  Picture a car combat game where you have to keep buying gas.  Tamagotchis were essentially giant drains &#8211; you had to keep feeding and playing with your virtual pet, or else it would die and you&#8217;d brick your device.</p>
<p>The Sims characters are on constant drains &#8211; their hunger, happiness, fun and social lives are constantly sapped as you play.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/sims.jpg" alt="The Sims"></p>
<p>That&#8217;s funny &#8230; i feel MY fun being sapped as i play.
</p></div>
<p>If you build out a lot of gameplay beyond keeping your virtual parasite happy and emotionally well-adjusted, completing mundane tasks like feeding and watering your online identity becomes a bore.  So you can sell players items like auto-plant feeders, dog-walking services and extra gas tanks, instead of making players drill for their own crude.</p>
<h2>Charity Items</h2>
<p>i very much like the idea of virtual items that are tied to some sort of charitable cause.  The red movement pulled this off with their Facebook gifts, and i can see it working elsewhere as well.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/charity.jpg" alt="Red Charity"></p>
<p>Pilfe(red).
</p></div>
<h2>Insurance</h2>
<p>You haven&#8217;t yet seen a virtual world where a tsunami hits your virtual house while you&#8217;re away and wipes out all your tchotchkes. That&#8217;s because i haven&#8217;t designed my own virtual world yet.  But in my dystopian vision, you can buy fire, theft, flood and gigantic lizard insurance to protect your goodies from various Acts of Ryan.</p>
<h2>Feature Locks</h2>
<p>At the beginning of most virtual worlds, you design your avatar and choose a house. The designer can then lock these two features, and others like it, forevermore.  Once you choose your look, that&#8217;s it.  It&#8217;s done.  Once you choose a neighbourhood to live in, you have to abide by that choice.  Once you choose your character&#8217;s name, it&#8217;s locked in for all time.</p>
<p>This enables you to charge a lofty real-world price for a key game feature that you&#8217;ve <em>already built</em>.  Charge the player a &#8220;plastic surgery&#8221; fee to go back into the character creator tool.  Good fun.</p>
<h2>Step Right Up</h2>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/barnum.jpg" alt="The Art of Money Getting"></p>
<p>Best. Entrepreneurship book title. Evar.
</p></div>
<p>As you can see, you need to be a bit of a PT Barnum type in order sell virtual items online.  We&#8217;re talking about selling something that has no inherent value, that costs you zero dollars to reproduce, and that lives or dies on the human psychological foibles you&#8217;re able to tap into.  The morality of all this may be questionable, and i&#8217;ve heard some folks call virtual item sales downright evil, especially when it comes to selling virtual items to children.  But i have another perspective:</p>
<ol>
<li>Having been a child myself (and, in fact, remaining so to a large extent), i know first-hand the <em>real</em> joy that a <em>virtual</em> thing can bring.  Some of the most amazing places i&#8217;ve been, some of the most interesting people i&#8217;ve met, and some of the funniest things i remember have all been from video games, while many of my real-life experiences have fallen far short of my virtual experiences.
<p>And when i laid that last sticker down in my Panini He-Man and the Masters of the Universe sticker album, i knew that the scads of allowance money i&#8217;d burned collecting those stickers had been <em>worth it</em>.  In my own small child universe, i had accomplished something.  i had followed through, and i had achieved.</p>
<p>And today, employing much of the same determination, focus, and vision, i continue to achieve.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_29/princeAdam.jpg" alt="Prince Adam"></p>
<p>Thanks to He-Man, i am also aggressively homosexual.
</p></div>
<li>If rich people are so well-off that they have nothing better to do than to spend their money on non-existent items, more power to them.  i willl gladly take their money and build out the charitable arm of my company, so that real people with real needs can eat real food.
</ol>
<p>This way to the great egress!</p>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2009%2F09%2F29%2Fthe-8-types-of-items-in-multiplayer-games%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2009%2F09%2F29%2Fthe-8-types-of-items-in-multiplayer-games%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2009/09/29/the-8-types-of-items-in-multiplayer-games/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=1844&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2009/09/29/the-8-types-of-items-in-multiplayer-games/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Five Common AS3 to UnityScript Translations</title>
		<link>http://www.untoldentertainment.com/blog/2009/09/25/five-common-as3-to-unityscript-translations/</link>
		<comments>http://www.untoldentertainment.com/blog/2009/09/25/five-common-as3-to-unityscript-translations/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 17:05:06 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=1832</guid>
		<description><![CDATA[i&#8217;ve been using Unity3D on and off for a week now. i&#8217;d burned through about a dozen beginner tutorials, and am a little overwhelmed by how much i don&#8217;t know about the engine, which enables you to create 3D games to deploy to a number of platforms, including the iPhone and web browsers. i&#8217;d look [...]]]></description>
			<content:encoded><![CDATA[<p>i&#8217;ve been using Unity3D on and off for a week now.  i&#8217;d burned through about a dozen beginner tutorials, and am a little overwhelmed by how much i <em>don&#8217;t</em> know about the engine, which enables you to create 3D games to deploy to a number of platforms, including the iPhone and web browsers.</p>
<p>i&#8217;d look like a fool if i tried to write a tutorial at this point. So instead, i&#8217;ll share this list of translations of common Actionscript 3 coding tasks to the Unity3D engine&#8217;s JavaScript-like UnityScript language.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_25/flashToUnity.jpg" alt="Flash to Unity"></p>
</div>
<h2>1. Render an Object Visible or Invisible</h2>
<p><b>Actionscript 3:</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">thing.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #808080; font-style: italic;">// or false</span></pre></div></div>

<p><b>UnityScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">thing.<span style="color: #660066;">renderer</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// or false</span></pre></div></div>

<h2>2. Tint an Object</h2>
<p><b>Actionscript 3:</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> colorTransform:ColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
colorTransform.<span style="color: #0066CC;">color</span> = 0xFF0000;
thing.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span>=colorTransform;</pre></div></div>

<p><b>UnityScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">thing.<span style="color: #660066;">renderer</span>.<span style="color: #660066;">material</span>.<span style="color: #660066;">color</span> <span style="color: #339933;">=</span> Color.<span style="color: #660066;">red</span><span style="color: #339933;">;</span></pre></div></div>

<h2>3. Get a Random Number</h2>
<p><b>Actionscript 3:</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> someRandomNumberBetween0And5:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><b>UnityScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> someRandomNumberBetween0And5<span style="color: #339933;">:</span>int <span style="color: #339933;">=</span> Random.<span style="color: #660066;">Range</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>4. Respond to a Key Press</h2>
<p><b>Actionscript 3:</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span>, doKeyDown<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doKeyDown<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">keyCode</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">32</span>:
			<span style="color: #808080; font-style: italic;">// Space bar! Do stuff.</span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #000000; font-weight: bold;">default</span>:
			<span style="color: #b1b100;">break</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>UnityScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>Input.<span style="color: #660066;">GetKeyDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;space&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Do stuff.</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>5. Open a Web Page</h2>
<p><b>Actionscript 3:</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">navigateToURL<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">URL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.untoldentertainment.com&quot;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;_self&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><b>UnityScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Application.<span style="color: #660066;">OpenURL</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.untoldentertainment.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div class="displayed">
<p><a href="http://www.untoldentertainment.com/blog/unity-nuub/"><img src="http://www.untoldentertainment.com/blog/img/features/unityNuub/unityNuub.jpg"></a></p>
</div>
<div class="tweetmeme_button" style="margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2009%2F09%2F25%2Ffive-common-as3-to-unityscript-translations%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.untoldentertainment.com%2Fblog%2F2009%2F09%2F25%2Ffive-common-as3-to-unityscript-translations%2F&amp;source=untoldent&amp;style=normal&amp;service_api=R_44463fc40e5eda8ec585b4088e695066&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.untoldentertainment.com/blog/2009/09/25/five-common-as3-to-unityscript-translations/" /></p><img src="http://www.untoldentertainment.com/blog/?ak_action=api_record_view&id=1832&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.untoldentertainment.com/blog/2009/09/25/five-common-as3-to-unityscript-translations/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Tutorial &#8211; Understanding Classes in AS3 Part 4</title>
		<link>http://www.untoldentertainment.com/blog/2009/09/24/tutorial-understanding-classes-in-as3-part-4/</link>
		<comments>http://www.untoldentertainment.com/blog/2009/09/24/tutorial-understanding-classes-in-as3-part-4/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 13:25:25 +0000</pubDate>
		<dc:creator>Ryan Henson Creighton</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.untoldentertainment.com/blog/?p=1787</guid>
		<description><![CDATA[In this tutorial, you&#8217;ll learn about the OOP (Object-Oriented Programming) concept of encapsulation, and how to break encapsulation to get stuff done in a decent amount of time. Technical Correctness vs. Getting Sh*t Done i&#8217;ve been really happy with the way this series has been received. If you&#8217;re like me, you&#8217;ve had a hard time [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, you&#8217;ll learn about the OOP (Object-Oriented Programming) concept of <em>encapsulation</em>, and how to break encapsulation to get stuff done in a decent amount of time.</p>
<h2>Technical Correctness vs. Getting Sh*t Done</h2>
<p>i&#8217;ve been really happy with the way this series has been received. If you&#8217;re like me, you&#8217;ve had a hard time understanding the big deal about OOP and Classes &#8211; you know it&#8217;s something you&#8217;ve got to bite the bullet and eventually learn, but it seems like a whole lot of extra typing for nothing.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/catOnKeyboard.jpg" alt="Cat on keyboard"></p>
<p>i&#8217;ve been typing for friggin&#8217; HOURS!
</p></div>
<p>But for those of us designers-turned-coders who have embraced Classes (or have been forced into using them for a paid project with a deadline), we&#8217;ll tell you that when written the &#8220;right&#8221; way, Classes can free you from writing a lot of code in your next project.</p>
<p>The trouble comes when you know so much about Classes that you write them <em>too</em> correctly.  You can definitely spend too much time making a Class all things to all people and for all purposes.  &#8220;It&#8217;s a MegaClass that can be an animated sprite AND a media player!  It&#8217;s so VERSATILE!&#8221;  Meanwhile, you either haven&#8217;t launched a game in a year, or your clients are calling every other hour wondering how their project is coming along.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/kidsInBackSeat.jpg" alt="Kids in back seat"></p>
<p>Are we there yet? Are we there yet? Are we there yet? Are we there yet?
</p></div>
<h2>Let&#8217;s Recap</h2>
<p>In <a href="http://www.untoldentertainment.com/blog/2009/08/25/tutorial-understanding-classes-in-as3-part-1/">Understanding Classes Part 1</a>, you freed yourself from the timeline.  In <a href="http://www.untoldentertainment.com/blog/2009/09/09/tutorial-understanding-classes-in-as3-part-2/">Part 2</a>, you took a little detour and learned how to piggyback your library to write custom MovieClip symbols using <em>inheritance</em>.  In <a href="http://www.untoldentertainment.com/blog/2009/09/15/tutorial-understanding-classes-in-as3-part-3/">Part 3</a>, you started looking at how code could be organized in separate files to keep your workspace light, and to better organize your work.  Now let&#8217;s take a look at the next principle of OOP, <em>encaspulation</em>, to see if we can&#8217;t turn our Classes into true drag-and-drop Lego bricks.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/encapsulation.jpg" alt="OOP Encapsulation"></p>
<p>Good encapsulation makes dinosaurs happen.  Bad encapsulation makes the dinosaurs go crazy and kill people.
</p></div>
<h2>Lego, Ikea furniture, and Your Code</h2>
<p>Once again, the three principles of Object-Oriented Programming are <em>inheritance</em>, <em>encapsulation</em>, and <em>polymorphism</em>.  </p>
<p>Think of your Classes as Lego bricks.  You want to build a Media Player brick that works in your current project, that you can lift out and snap into your next project that requires a Media Player, with no extra work required.  That&#8217;s the dream, anyway.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/lego.jpg" alt="Lego"></p>
<p>You want your code to be less time-consuming.  You know &#8211; like Lego.
</p></div>
<p>Up to this point, i&#8217;ve recommended that you make all of your Classes&#8217; fields (things that a Class <em>is</em>) and methods (things that a Class <em>does</em>) <b>public</b>. Public variables and methods can be accessed by anyone and anything outside the Class.</p>
<p>Let&#8217;s look at some code. We have an ImageGallery Class and our Main Class.  Main creates an instance (stamp, version, print) of ImageGallery and draws it to the screen using addChild:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ImageGallery <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> numberOfImagesICanDisplay:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">5</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ImageGallery<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// Display numberOfImagesICanDisplay</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> imageGallery:ImageGallery = <span style="color: #000000; font-weight: bold;">new</span> ImageGallery<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>imageGallery<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So far so good.  But take a close look at that variable on ImageGallery:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> numberOfImagesICanDisplay:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">5</span>;</pre></div></div>

<p>That field is declared <b>public</b>.  That means that any idiot (including YOU) can access that field and change it.  Let&#8217;s be a total jackwad and, from Main, change it to eight million:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">		imageGallery.<span style="color: #006600;">numberOfImagesICanDisplay</span>:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">8000000</span>;</pre></div></div>

<p>This messes up ImageGallery&#8217;s pyjama party to the very limit.  How is ImageGallery supposed to display eight million photos?  It&#8217;s only really set up to handle five images.  There HAS to be a way to protect important variables like numberOfImagesICanDisplay from other ass-hat Classes like Main.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/terminator.jpg" alt="Terminator"></p>
<p>i recommend sending the Terminator back in time to prevent yourself from messing with that variable.
</p></div>
<h2>Stop Looking at My Privates</h2>
<p>Fortunately, there is a better and less future-altering way. If we change <b>public</b> to <b>private</b>, only instances (copies, stamps) of the ImageGallery Class can read and write the value of that field.  Hooray!</p>
<p>The way i suggested you write your Classes was completely backards. <b>Public</b> is the <em>most permissive</em> access modifier. <b>Private</b> is the <em>least permissive</em> access modifier. </p>
<p>The rule i&#8217;ve read is that you should always start out restrictive, declaring everything <b>private</b>, because once you go <b>public</b> it&#8217;s kinda hard to go back to <b>private</b>.  (If you were an early bloomer in high school who &#8220;went public&#8221;, you&#8217;ll know how difficult it is to regain your privacy)</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/schoolgirl.jpg" alt="Slutty schoolgirl"></p>
<p>It&#8217;s hard to recover from going public
</p></div>
<p>So declare everything &#8211; methods and fields/variables &#8211; <em>private</em>.  If you find that any outside Classes need to access those methods and fields later, you can open them up by making them <em>public</em>.</p>
<h2>What Should I Make Public?</h2>
<p>Object-oriented programming eggheads are pretty particular about the kinds of things that should be public, and those that should be private.  The example i&#8217;ve heard is to think of a device like a vending machine.  There are certain client-facing input methods that need to be accessible to the outside world:</p>
<ul>
<li>insert coin
<li>push snack button
<li>push coin return button
</ul>
<p>And there are certain things the vending machine is going to return to the person using it:</p>
<ul>
<li>snacks
<li>coins
<li>error messages (&#8220;SOLD OUT&#8221;, INCORRECT CHANGE&#8221;, &#8220;NO CANDY FOR YOU, FATTY&#8221;, etc)
</ul>
<p>So the vending machine accepts input and dispenses output.  <em>Everything else is private</em>.  The user does not need to be able to control the coils that turn to dispense the snacks.  The user has no business figuring out how to make change inside the machine, or managing the vending machine&#8217;s inventory of goodies.  That&#8217;s all internal stuff.  That&#8217;s private.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/vendingMachine.jpg" alt="Vending Machine"></p>
<p>None shall know the labyrinthine secrets of the vending machine!  MWA HA HA HA HA!!
</p></div>
<h2>Dispatching Events</h2>
<p>We already know how to write a public method on a Class, and we learned how to pass a <em>parameter</em> through to the Class.  Here&#8217;s a snippet from an imaginary vending machine Class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> insertCoin<span style="color: #66cc66;">&#40;</span>coin:Coin<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// Tally up the value of the coin that has been inserted</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>coin.<span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;quarter&quot;</span>:
			coinValue += <span style="color: #cc66cc;">25</span>;
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;dime&quot;</span>:
			coinValue += <span style="color: #cc66cc;">10</span>;
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;nickel&quot;</span>:
			coinValue += <span style="color: #cc66cc;">5</span>;
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;penny&quot;</span>:
			<span style="color: #808080; font-style: italic;">// No pennies!</span>
			<span style="color: #b1b100;">return</span> coin<span style="color: #66cc66;">&#40;</span>coin<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">break</span>;
		<span style="color: #000000; font-weight: bold;">default</span>:
			<span style="color: #b1b100;">break</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And here&#8217;s an example of how you might call that function from outside the Class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">vendingMachine.<span style="color: #006600;">insertCoin</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Quarter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>In Actionscript 3, the <em>proper</em> way to signal to the outside world that something important has happened <em>inside</em> a Class is to fire an even dispatcher.  Here&#8217;s what that looks like in our imaginary vending machine Class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// This line goes at the top of the Class where you declare your fields:</span>
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const RETURN_SNACK:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;returnSnack&quot;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// And then later, when you declare your methods:</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> returnSnack<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>RETURN_SNACK<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And here&#8217;s how you listen for that event in the Main Class (or from whichever Class instantiates [makes a copy of] the vending machine):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Make sure you import the generic Event stuff near the top of the file:</span>
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">Events</span>.<span style="color: #006600;">event</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// This is what your instantiation and listener definition look like:</span>
<span style="color: #000000; font-weight: bold;">var</span> vendingMachine:VendingMachine = <span style="color: #000000; font-weight: bold;">new</span> VendingMachine<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
vendingMachine.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>VendingMachine.<span style="color: #006600;">RETURN_SNACK</span>, getASnack<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// And elsewhere, you define the method to respond to the event:</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getASnack<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// HOORAY FOAR SNAKZ!!!</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Anyone see a problem yet?  i do.  We&#8217;re not really able to pass a parameter back to Main through our dispatchEvent command.  So how does Main know what kind of snack it received?</p>
<p>There are a few ways around this.  We can store a variable on Main called requestedSnack and take it on faith that vendingMachine returns the correct snack.  Or, we can create a public variable on VendingMachine to store the returnedSnack, and in Main&#8217;s getASnack method, we refer to vendingMachine.returnedSnack.  And then there are super egghead ways to do it that remain mysterious to me.</p>
<div class="displayed">
<p><img src="http://www.untoldentertainment.com/blog/img/2009_09_24/nerd.jpg" alt="Nerd"></p>
<p>i am not well-versed in the Way of the Nerd.
</p></div>
<h2>Let&#8217;s Get Ready to Fudge It</h2>
<p>But here&#8217;s the CHEATERPANTS way of doing things.  Using dispatchEvent is nice, because we can plop this vending machine down in any other game or app and it WORKS.  It&#8217;s <em>encapsulated</em>.  There are no dependancies.  We just need to listen to all of its dispatched events in the new file, and we&#8217;re gold.  But to be honest, that&#8217;s a whole lot more typing, and i&#8217;ve got things to do.</p>
<p>The cheaty way to do it is to pass a reference to Main as a parameter to the VendingMachine Class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// From Main:</span>
<span style="color: #000000; font-weight: bold;">var</span> vendingMachine:VendingMachine = <span style="color: #000000; font-weight: bold;">new</span> VendingMachine<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// From VendingMachine:</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> VendingMachine<span style="color: #66cc66;">&#40;</span>main:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// And then later in VendingMachine:</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dispenseSnack<span style="color: #66cc66;">&#40;</span>snack:Snack<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void
