<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mat janson blanchet</title>
	<atom:link href="http://jansensan.net/feed" rel="self" type="application/rss+xml" />
	<link>http://jansensan.net</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 00:50:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to fully fit an Away3D plane in the viewport</title>
		<link>http://jansensan.net/how-to-fully-fit-away3d-plane-in-viewport</link>
		<comments>http://jansensan.net/how-to-fully-fit-away3d-plane-in-viewport#comments</comments>
		<pubDate>Mon, 06 Feb 2012 00:50:12 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Stage3D]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=756</guid>
		<description><![CDATA[
There has been a lot of people who played with Away3D and built awesome things. A lot of said awesome things were built by people who know, or know someone that knows 3D modeling, which is why the quality has been so awesome. However, it may not always be necessary to build a full 3D [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Escher - Relativity (Detail)" src="http://jansensan.net/images/blog/post0029-escher-header.jpg" alt="Escher - Relativity (Detail)" width="640" height="220" /></p>
<p>There has been a lot of people who played with <a title="Away3D" href="http://away3d.com/" target="_blank">Away3D</a> and built awesome things. A lot of said awesome things were built by people who know, or know someone that knows 3D modeling, which is why the quality has been so awesome. However, it may not always be necessary to build a full 3D world, sometimes a project may simply require some 3D elements over a 2D background. But how do you place an image behind all sorts of 3D objects if Away3D's <code><a title="Away3D View3D source" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/containers/View3D.as" target="_blank">View3D</a></code> has a black background? I will try and explain the process in this article. Warning: matrices and trigonometry ahead!</p>
<p><strong>Build it and they will come</strong></p>
<p>Usually, if you want to place an image and make it fit your document dimensions, you simply stretch the image accordingly. In 3D however, it is not as simple, as the world dimensions are not necessarily measured in pixels. While working with the guys from <a title="Float4 Interactive" href="http://float4.com/" target="_blank">Float4</a>, I came to understand that meters are oftentimes used as measurement unit. With that in mind, we cannot directly use the dimensions of our document.</p>
<p>So let's say we want to place an image in the 3D world and make it fill the viewport (the visual space taken by Away3D). At first, we would need an image, and a plane onto which we would like to place the image. As <a title="Apply a texture on a cube in Away3D 4.0" href="http://jansensan.net/apply-a-texture-on-a-cube-in-away3d-4-0" target="_self">I wrote previously</a>, materials applied onto shapes need to be in dimensions that are a power of 2, so will will need to rescale our image. A <code><a title="AS3 Matrix documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix.html" target="_blank">Matrix</a></code> will fulfill this need.</p>
<blockquote>
<pre class="actionscript"><span style="color: #0066CC;">private</span> const <span style="color: #0066CC;">WIDTH</span>:uint = <span style="color: #cc66cc;">640</span>;
<span style="color: #0066CC;">private</span> const <span style="color: #0066CC;">HEIGHT</span>:uint = <span style="color: #cc66cc;">640</span>;
<span style="color: #0066CC;">private</span> const MATERIAL_WIDTH:uint = <span style="color: #cc66cc;">1024</span>;
<span style="color: #0066CC;">private</span> const MATERIAL_HEIGHT:uint = <span style="color: #cc66cc;">1024</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">&quot;assets/images/escher-relativity.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">private</span> const EscherImageClass:<span style="color: #000000; font-weight: bold;">Class</span>;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _imageData:BitmapData;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _matrix:Matrix;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _material:BitmapMaterial;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _plane:Plane;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _view3D:View3D;</pre>
</blockquote>
<p><code>WIDTH</code> and <code>HEIGHT</code> represent the dimensions of my document, and also the dimensions of the image. The <code>MATERIAL_WIDTH</code> and <code>MATERIAL_HEIGHT</code> represent the dimensions needed for the material, dimensions that are a power of two. Here I will be using an image from <a title="M. C. Escher on Wikipedia" href="http://en.wikipedia.org/wiki/M._C._Escher" target="_blank">Escher</a>, obtained from Wikipedia. There is no need for a <code><a title="AS3 Bitmap documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Bitmap.html" target="_blank">Bitmap</a></code> per se, but we will need the image's <code><a title="AS3 BitmapData documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html" target="_blank">BitmapData</a></code>, hence the <code>_imageData</code> variable.</p>
<p>Let's do this!</p>
<p>Normally, I resize the material dimensions to a value higher than what I need to display; first the material is stretched up, and then visually fitted to the original dimensions of the image. If we were to scale the material to smaller dimensions than that of the image, the plane would stretch up the material afterwards when displaying the image, resulting in possible loss of smoothness or detail.</p>
<blockquote>
<pre class="actionscript">_matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_matrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>MATERIAL_WIDTH / <span style="color: #0066CC;">WIDTH</span>, MATERIAL_HEIGHT / <span style="color: #0066CC;">HEIGHT</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Let's draw an instance of the Escher image into the<code>_imageData</code>. This is where <code>_matrix</code> comes in handy. I wonder what pushed Adobe's engineers to make an architectural choice where they thought users would use a <code><a title="AS3 ColorTransform documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/ColorTransform.html" target="_blank">ColorTransform</a></code>, a <code><a title="AS3 BlendMode documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BlendMode.html" target="_blank">BlendMode</a></code> or a clipping <code><a title="AS3 Rectangle documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Rectangle.html" target="_blank">Rectangle</a></code> more often than a flag to smooth the drawing. I mean, putting the flag as a last argument? Anywho, let's add a lot of <code>null</code> parameters...</p>
<blockquote>
<pre class="actionscript">_imageData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>MATERIAL_WIDTH, MATERIAL_HEIGHT<span style="color: #66cc66;">&#41;</span>;
_imageData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> EscherImageClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _matrix, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Next, create the material. As seen <a title="Apply a texture on a cube in Away3D 4.0" href="http://jansensan.net/apply-a-texture-on-a-cube-in-away3d-4-0" target="_blank">previously</a>, let's use a simple trick to assign whether or not the material is mipmapped.</p>
<blockquote>
<pre class="actionscript">_material = <span style="color: #000000; font-weight: bold;">new</span> BitmapMaterial<span style="color: #66cc66;">&#40;</span>_imageData, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
_material.<span style="color: #006600;">mipmap</span> = <span style="color: #66cc66;">&#40;</span>_imageData.<span style="color: #0066CC;">width</span> == _imageData.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Apply the material to the plane, add the plane to the <code><a title="Away3D View3D source" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/containers/View3D.as" target="_blank">View3D</a></code>, and then add the view to the display list.</p>
<blockquote>
<pre class="actionscript">_plane = <span style="color: #000000; font-weight: bold;">new</span> Plane<span style="color: #66cc66;">&#40;</span>_material<span style="color: #66cc66;">&#41;</span>;
_view3D = <span style="color: #000000; font-weight: bold;">new</span> View3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_view3D.<span style="color: #006600;">scene</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>_plane<span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span>_view3D<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Do not forget to listen to <code>Event.ENTER_FRAME</code> and call the <code><a title="Away3D View3D.render() documentation" href="http://away3d.com/livedocs/away3d-core-fp11/away3d/containers/View3D.html#render()" target="_blank">View3D.render()</a></code> method at every update.</p>
<blockquote>
<pre class="actionscript">addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, updateHandler<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Run it, and what do we get?...</p>
<p>Nothing.</p>
<p>Uh?</p>
<p>By default, the plane is added at (0, 0, 0), so it should be visible...</p>
<p>It is, it turns out that an API choice—which may make sense in a 3D world, but that I do not understand—puts the plane with its face up on instantiation. What this means is when it is created, we see its side, which has no thickness. Just change the <code>yUp</code> parameter to <code>false</code>, so the new plane will then face the camera upon creation.</p>
<blockquote>
<pre class="actionscript">_plane.<span style="color: #006600;">yUp</span> = <span style="color: #000000; font-weight: bold;">false</span>;</pre>
</blockquote>
<p>We should get something like this.</p>
<p><img class="alignnone" title="Plane is too close, image is cropped by viewport" src="http://jansensan.net/images/blog/post0029-escher-too-big.jpg" alt="Plane is too close, image is cropped by viewport" width="640" height="640" /></p>
<p>If we compare the image and this result, we notice that the image's edges are cropped, which means the plane is too close. Below is a diagram explaining this visually.</p>
<p><img class="alignnone" title="Diagram - too big, outside of viewport" src="http://jansensan.net/images/blog/post0029-too-big-diagram.jpg" alt="Diagram - too big, outside of viewport" width="640" height="272" /></p>
<p>Imagine a pyramid drawn from the camera at its top with an angle that is the camera's <a title="Field of view on Wikipedia" href="http://en.wikipedia.org/wiki/Field_of_view" target="_blank">field of view</a>, up until a certain point. From the camera's point of view, there is always a certain frame that is visible, that is the viewport. However, that pyramid is not infinite, actually what the camera sees is not even a pyramid. The <a title="Viewing frustum on Wikipedia" href="http://en.wikipedia.org/wiki/Viewing_frustum" target="_blank">viewing frustum</a>, what is visible within a 3D world, is an area from a certain threshold (the near plane) to another one (the far plane), that's what is visible within a 3D world. What happens with the code above is that the plane is bigger than the frustum, thus being cut.</p>
<p>Below is what we want to achieve:</p>
<p><img class="alignnone" title="Diagram - Plane fits into the viewport" src="http://jansensan.net/images/blog/post0029-viewport-diagram.jpg" alt="Diagram - Plane fits into the viewport" width="640" height="240" /></p>
<p><strong>SOH-CAH-TOA</strong></p>
<p>This is where the fun begins! How do we fit our plane into our viewport? It is possible to simply move the plane on the z axis and eventually position the plane properly to fit our need. But what if the dimensions change? We'd be back onto square one. This problem requires good ol' trigonometry, and the pythagorean theorem.</p>
<p>You may wonder what this title means. It's a mnemonic trick that's been given to me back in high school on how to remember the rules of trigonometry:</p>
<blockquote><p><strong>S</strong>ine of an angle = <strong>O</strong>pposite side / <strong>H</strong>ypothenuse</p>
<p><strong>C</strong>osine of an angle = <strong>A</strong>djacent side / <strong>H</strong>ypothenuse</p>
<p><strong>T</strong>angent of an angle = <strong>O</strong>pposite side / <strong>A</strong>djacent side</p></blockquote>
<p>Then let's consider this as a trigonometry problem, illustrated below. We have a camera, the <code><a title="Away3d Camera3D source" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/cameras/Camera3D.as" target="_blank">Camera3D</a></code>, which is located at (0, 0, -500) by default. Look at the sources to confirm, it is the case with Away3D, but it may be different in other 3D engines. We have a plane with a position yet undefined, but we do want to make sure that its fits perfectly into the viewport.</p>
<p><img class="alignnone" title="Diagram - trigonometry and pythagorean theorem" src="http://jansensan.net/images/blog/post0029-z-diagram.jpg" alt="Diagram - trigonometry and pythagorean theorem" width="640" height="240" /></p>
<p>Where does that 60° angle in the illustration above come from? If we take a look at the <code><a title="Away3D Camera3D source" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/cameras/Camera3D.as" target="_blank">Camera3D</a></code> constructor, we find that it uses a <code><a title="Away3D PerspectiveLens source" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/cameras/lenses/PerspectiveLens.as" target="_blank">PerspectiveLens</a></code> by default. In that lens constructor, we can see the default field of view is 60, which is in degrees. It's too bad we need to look at the source to obtain this, it would have been simpler to use a getter to be able to check it, but there is none.</p>
<p>Good, we have an angle, we can calculate dimensions and positions. Let's set an arbitrary z for the plane, we'll see further that it doesn't matter.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> angleY:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">60</span>;
<span style="color: #000000; font-weight: bold;">var</span> cameraZ:<span style="color: #0066CC;">int</span> = _view3D.<span style="color: #0066CC;">camera</span>.<span style="color: #006600;">z</span>;
<span style="color: #000000; font-weight: bold;">var</span> planeZ:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">500</span>;
<span style="color: #000000; font-weight: bold;">var</span> distFromCamToPlane:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>cameraZ<span style="color: #66cc66;">&#41;</span> + planeZ;</pre>
</blockquote>
<p>Since the field of view is vertical, let's measure the height of our plane first. Let's not forget that the field of view covers the whole height, but in order to work with rectangle triangles, we will use only half of that angle. We know the angle, we know the distance from the camera to the plane (the adjacent side), but we do not know the opposite side, so let's use the tangent. The <code><a title="AS3 Math.tan() documentation" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Math.html#tan()" target="_blank">Math.tan()</a></code> takes radians, so just make sure to convert those degrees to radians.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> planeHeight:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">tan</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>angleY * <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> * distFromCamToPlane;</pre>
</blockquote>
<p>Since this represents only half of the height, let's correct it for what we need further.</p>
<blockquote>
<pre class="actionscript">planeHeight *= <span style="color: #cc66cc;">2</span>;</pre>
</blockquote>
<p>To obtain the width of our plane, simply apply the aspect ratio of the image. In this case the image is a square, but it may very well be any kind of rectangle.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> aspectRatio:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">WIDTH</span> / <span style="color: #0066CC;">HEIGHT</span>;
<span style="color: #000000; font-weight: bold;">var</span> planeWidth:<span style="color: #0066CC;">int</span> = planeHeight * aspectRatio;</pre>
</blockquote>
<p>And now we are ready to create our plane with the proper dimensions and position.</p>
<blockquote>
<pre class="actionscript">_plane = <span style="color: #000000; font-weight: bold;">new</span> Plane<span style="color: #66cc66;">&#40;</span>_material, planeWidth, planeHeight<span style="color: #66cc66;">&#41;</span>;
_plane.<span style="color: #006600;">yUp</span> = <span style="color: #000000; font-weight: bold;">false</span>;
_plane.<span style="color: #006600;">z</span> = planeZ;</pre>
</blockquote>
<p>Let's take a look at the whole process at once.</p>
<blockquote>
<pre class="actionscript"><span style="color: #808080; font-style: italic;">// get the scale to apply to the image</span>
_matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_matrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>MATERIAL_WIDTH / <span style="color: #0066CC;">WIDTH</span>, MATERIAL_HEIGHT / <span style="color: #0066CC;">HEIGHT</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// create the image data</span>
_imageData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>MATERIAL_WIDTH, MATERIAL_HEIGHT<span style="color: #66cc66;">&#41;</span>;
_imageData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> EscherImageClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _matrix, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// create the material</span>
_material = <span style="color: #000000; font-weight: bold;">new</span> BitmapMaterial<span style="color: #66cc66;">&#40;</span>_imageData, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
_material.<span style="color: #006600;">mipmap</span> = <span style="color: #66cc66;">&#40;</span>_imageData.<span style="color: #0066CC;">width</span> == _imageData.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// create the view</span>
_view3D = <span style="color: #000000; font-weight: bold;">new</span> View3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// camera values</span>
<span style="color: #808080; font-style: italic;">// see away3d.camerasCamera3D's default lens' field of view</span>
<span style="color: #808080; font-style: italic;">// in away3d.cameras.lenses.PerspectiveLens</span>
<span style="color: #808080; font-style: italic;">// it turns out that the field of view is vertical</span>
<span style="color: #000000; font-weight: bold;">var</span> angleY:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">60</span>;
<span style="color: #000000; font-weight: bold;">var</span> cameraZ:<span style="color: #0066CC;">int</span> = _view3D.<span style="color: #0066CC;">camera</span>.<span style="color: #006600;">z</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// this position is arbitrary as we will see further</span>
<span style="color: #808080; font-style: italic;">// useful to calculate the distance between the camera and the plane</span>
<span style="color: #000000; font-weight: bold;">var</span> planeZ:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">500</span>;
<span style="color: #000000; font-weight: bold;">var</span> distFromCamToPlane:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>cameraZ<span style="color: #66cc66;">&#41;</span> + planeZ;
&nbsp;
<span style="color: #808080; font-style: italic;">// since the field of view is a vertical angle, calculate the height of the plane first</span>
<span style="color: #808080; font-style: italic;">// use pythagorean theorem to calculate</span>
<span style="color: #808080; font-style: italic;">// tip for trigonometry: soh-cah-toa</span>
<span style="color: #808080; font-style: italic;">// toa: tan(angle) = oppositeSide / adjacentSide</span>
<span style="color: #000000; font-weight: bold;">var</span> planeHeight:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">tan</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>angleY * <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> * distFromCamToPlane;
&nbsp;
<span style="color: #808080; font-style: italic;">// and since it was for a rectangle triangle, thus half the size, double the length</span>
planeHeight *= <span style="color: #cc66cc;">2</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// useful for resizing the image</span>
<span style="color: #000000; font-weight: bold;">var</span> aspectRatio:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">WIDTH</span> / <span style="color: #0066CC;">HEIGHT</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// use the aspect ratio to calulcate the width of the plane</span>
<span style="color: #000000; font-weight: bold;">var</span> planeWidth:<span style="color: #0066CC;">int</span> = planeHeight * aspectRatio;
&nbsp;
<span style="color: #808080; font-style: italic;">// create the plane</span>
_plane = <span style="color: #000000; font-weight: bold;">new</span> Plane<span style="color: #66cc66;">&#40;</span>_material, planeWidth, planeHeight<span style="color: #66cc66;">&#41;</span>;
_plane.<span style="color: #006600;">yUp</span> = <span style="color: #000000; font-weight: bold;">false</span>;
_plane.<span style="color: #006600;">z</span> = planeZ;
&nbsp;
<span style="color: #808080; font-style: italic;">// add 3D objects to the scene</span>
_view3D.<span style="color: #006600;">scene</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>_plane<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// add the away3d view to the display list</span>
addChild<span style="color: #66cc66;">&#40;</span>_view3D<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// listen to the updates</span>
addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, updateHandler<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>This should produce a result like <a href="http://jansensan.net/experiments/fit-away3d-plane-fully-in-viewport/" target="_blank">this</a>, where the image fits perfectly in the viewport.</p>
<p><img class="alignnone" title="Plane fits viewport perfectly" src="http://jansensan.net/images/blog/post0029-full-view.jpg" alt="Plane fits viewport perfectly" width="640" height="640" /></p>
<p>For additional fun, I added an option to click to rotate it, so that it demonstrates that it is indeed 3D.</p>
<p><strong>Sources</strong></p>
<p>As I always do in my tutorials, you can download the <a title="Tutorial sources" href="http://bit.ly/plane-sources">sources</a>. This project has been built for Flash Player 11+ with FDT. You may need to adapt the Flex SDK.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/how-to-fully-fit-away3d-plane-in-viewport/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to improve localization</title>
		<link>http://jansensan.net/how-to-improve-localization</link>
		<comments>http://jansensan.net/how-to-improve-localization#comments</comments>
		<pubDate>Wed, 02 Nov 2011 18:19:24 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Localization]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Strategy]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=294</guid>
		<description><![CDATA[
I've been meaning to write about this for a while. Even though it is not specifically about development, user experience is something that creative developers should take into account when developing websites, games or other interactive experiences. Let's look at a couple of different ways of offering the user localized content, and try to analyze whether [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Hendrick van Cleve - The Construction of the Tower of Babel" src="http://jansensan.net/images/blog/post0028-babel.jpg" alt="Hendrick van Cleve - The Construction of the Tower of Babel" width="640" height="360" /></p>
<p>I've been meaning to write about this for a while. Even though it is not specifically about development, user experience is something that creative developers should take into account when developing websites, games or other interactive experiences. Let's look at a couple of different ways of offering the user localized content, and try to analyze whether these options fall flat on their face or offer enough flexibility to answer your client's and their customers's needs.</p>
<p>Clients that offer services in multiple countries require their content to be localized, and for a good reason: inhabitants of all regions of the world want to be respected and obtain content in their own language. And I agree, it's a simple matter of respect.</p>
<p><strong>The usual suspects</strong></p>
<p>The way localization is most often achieved is by detecting the user's country automatically. This can either be done by localizing the <a title="Wikipedia - IP" href="http://en.wikipedia.org/wiki/Internet_Protocol" target="_blank">IP</a> address (<a title="IP Address Localization" href="http://ip.bd0.net/" target="_blank">see an example</a>), soon by simpler means with HTML5's geolocation (<a title="HTML5 Geolocation Demo" href="http://html5demos.com/geo" target="_blank">see an example</a>) or by asking the user to select a country.</p>
<p><a title="LaCie" href="http://www.lacie.com/" target="_blank">LaCie</a> does just that.</p>
<p><img class="aligncenter" title="LaCie's landing page" src="http://jansensan.net/images/blog/post0028-lacie.jpg" alt="LaCie's landing page" width="640" height="360" /></p>
<p>I think that this last option is lazy, both on the company's and on the developer's part. The user should not have to make such choices, especially when there are ways to make such a selection invisible.</p>
<p>What happens from there is that the website content is presented in the language relative to the country. It mostly works, but there are some situations where this logic is not sufficient. Let's take the example of some European countries, like Belgium and Greece. In Belgium, French, Dutch (<a title="Wikipedia - Flemish" href="http://en.wikipedia.org/wiki/Flemish" target="_blank">Flemish</a>) and German are the official languages. In Greece, where obviously Greek is the language, there is also need for a <a title="Wikipedia - Greek Alphabet" href="http://en.wikipedia.org/wiki/Greek_alphabet" target="_blank">specific alphabet</a>.</p>
<p>From <a title="adidas.com" href="http://adidas.com" target="_blank">adidas</a>'s country selection page, if either Greece or Belgium is chosen, the user has no choice but to visit an English website.</p>
<p><img class="aligncenter" title="adidas language selection page" src="http://jansensan.net/images/blog/post0028-adidas-01.jpg" alt="adidas language selection page" width="640" height="360" /></p>
<p>To adidas's credit, there is the option to change country at any time, the site even offers you a choice whether or not you want the cookie to remember your country selection.</p>
<p><img class="aligncenter" title="adidas asks if the chosen country is to be remembered for next time" src="http://jansensan.net/images/blog/post0028-adidas-02.jpg" alt="adidas asks if the chosen country is to be remembered for next time" width="430" height="255" /></p>
<p>Some websites, such a <a title="nike.com" href="http://www.nike.com/" target="_blank">Nike</a>'s may offer a simpler solution, only choose your language, not the country.</p>
<p><img class="aligncenter" title="Nike's website offers to choose a language, not a country" src="http://jansensan.net/images/blog/post0028-nike.jpg" alt="Nike's website offers to choose a language, not a country" width="640" height="360" /></p>
<p>All these options ask an action from the user before they can even see your products or services, and that small irritant is the first interaction they have with your website.</p>
<p><strong>The mistaken</strong></p>
<p>In all online stores (let's not call these e-commerce no more, please?), there comes a moment where you want to write your shipping address to obtain your purchases. If you have offered your clients a multilingual website, it's just normal that the input fields should support special characters too, regardless of the language the client chose.</p>
<p>When I moved back from Amsterdam to Montréal, I had to change many addresses for many of my services, both physical and online.</p>
<p>Apple requires me to have a valid credit card in the country that I select, as their products availabilities are based on the locale. However, their form failed when I entered my address.</p>
<p><img class="aligncenter" title="Apple's address form" src="http://jansensan.net/images/blog/post0028-apple.jpg" alt="Apple's address form" width="620" height="360" />I get informed that the city, that I wrote "Montréal", contains illegal characters. Obviously, this turned out to be that I should not use the accent. This is ridiculous, the user should not be told there is something wrong when in fact there is not. How complicated is it really to handle accented characters? I mean, if you want to provide multilingual services, get your act together and do it everywhere.</p>
<p><strong>The ignorant</strong></p>
<p>There is also the peculiar case of Urban Outfitters. The american company has oftentimes been vilified for stealing designs from indie designers or for shamelessly using native names in their product names, so what I will present here should not come as a surprise.</p>
<p>In Québec, a law states that if a business has a brick and mortar store in the province, the business is responsible to also have a French side to it's website. As mentioned in my introduction, it's a matter of respect to your clients in the locale in which you offer your products and services.</p>
<p>Urban Outfitters did not, and when legally instructed to do so, they decided to simply not offer their clients in Québec with <a title="Urban Outfitters's Québec &quot;Website&quot;" href="http://www.urbanoutfitters.com/urban/html/quebec.html" target="_blank">no access to their website whatsoever</a>. Just go to the store.</p>
<p><img class="aligncenter" title="Urban Outfitters's fuck you to Quebeckers" src="http://jansensan.net/images/blog/post0028-urban.jpg" alt="Urban Outfitters's fuck you to Quebeckers" width="640" height="360" /></p>
<p>That is one stupid way to use geolocation! You disrespect a locale and it's language, and at the same time you prevent those in the locale who can speak and read English from having access to your products. Great way to prevent sales!</p>
<p><strong>The road ahead</strong></p>
<p>Of these different approaches I make the following conclusion and add a recommendation for multilingual website and software creators: first, indeed do geolocation to offer the most relevant content to the user. Do give options to change not only the country, but also the language. <a title="Paypal" href="https://www.paypal.com/" target="_blank">Paypal</a> is the closest to this idea. If you change your location to Canada, you can then change the language to the available languages is that country, namely French and English.</p>
<p>But here is where I want to get to with this post: why stop there? Indeed, do present the most logical languages relevant to that area, but do not block the other languages from being available, especially since you have them in the database already. I understand that it may be mostly be relevant for expats and travelers, but I strongly believe that this kind of market is growing.</p>
<p>The iTunes Store is built in order to lock you into a language depending on your country. Websites like <a title="YesAsia.com" href="http://yesasia.com/" target="_blank">YesAsia</a> are built with the idea that the content should be available to everyone, even if the clients are not from Hong Kong, Japan or Korea, where their offices are. They offer not only options for locales and languages, but a reference to the value of the currency so the customers may have a general idea of what they will pay.</p>
<p><img class="aligncenter" title="YesAsia's options" src="http://jansensan.net/images/blog/post0028-yesasia.jpg" alt="YesAsia's options" width="640" height="283" /></p>
<p>In the case of Paypal, as I said before languages are chosen by country. They have many more languages, they should offer them. I can understand that there may be issues in doing so. For example, English is not legally bounding in the Netherlands, so important options are not available, not even deleting an account. How about presenting all languages, and just like YesAsia does it, add a note that explains that whatever is said in translations, the version in the official language(s) of the locale prevail?</p>
<p>Ultimately, it's always about how much you really care about your clients. For example, Asian countries dislike it when they are presented with English text rather than localized. Ask your markets to help you make a better localized version of your products, don't just expect your clients to swallow whatever you feed them. This is the kind of stuff metrics will not really show in numbers, this is an analysis you can make from talking with your markets.</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/how-to-improve-localization/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apply a texture on a cube in Away3D 4.0</title>
		<link>http://jansensan.net/apply-a-texture-on-a-cube-in-away3d-4-0</link>
		<comments>http://jansensan.net/apply-a-texture-on-a-cube-in-away3d-4-0#comments</comments>
		<pubDate>Sat, 20 Aug 2011 19:02:41 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Broomstick]]></category>
		<category><![CDATA[Flash Player 11 Beta]]></category>
		<category><![CDATA[Molehill]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=692</guid>
		<description><![CDATA[
Now that your environment is set up to play with Away3D, let's create something! In my previous post, I concluded that you can now experiment, and so I did too. It turned out that there are some little intricacies about putting a simple image on a simple cube. Let's take a look.
Create a cube
This part [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Away3D cube with a texture applied" src="http://jansensan.net/images/blog/post0027_001.jpg" alt="Away3D cube with a texture applied" width="640" height="360" /></p>
<p>Now that your environment is <a title="Setting up FDT for Away3D and Flash Player 11 (Beta)" href="http://jansensan.net/setting-up-fdt-for-away3d-and-flash-player-11-beta" target="_blank">set up to play with Away3D</a>, let's create something! In my previous post, I concluded that you can now experiment, and so I did too. It turned out that there are some little intricacies about putting a simple image on a simple cube. Let's take a look.</p>
<p><strong>Create a cube</strong></p>
<p>This part has got to be the simplest, thanks to the nice API that the guys from Away3D built.</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript">package
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">containers</span>.<span style="color: #006600;">View3D</span>;
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">materials</span>.<span style="color: #006600;">ColorMaterial</span>;
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">primitives</span>.<span style="color: #006600;">Cube</span>;
&nbsp;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageAlign</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageScaleMode</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span>frameRate=<span style="color: #ff0000;">&quot;60&quot;</span>, <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#ffffff&quot;</span>, <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;640&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;360&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ VARS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span>	<span style="color: #000000; font-weight: bold;">var</span>	_view3D		:View3D;
	<span style="color: #0066CC;">private</span>	<span style="color: #000000; font-weight: bold;">var</span>	_cube		:Cube;
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ CONSTRUCTOR ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<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: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		initStage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, addedToStageHandler<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ PRIVATE METHODS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initStage<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: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
		<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<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: #808080; font-style: italic;">// it is necessary to add a texture to the shape so it is visible</span>
		<span style="color: #000000; font-weight: bold;">var</span> material:ColorMaterial = <span style="color: #000000; font-weight: bold;">new</span> ColorMaterial<span style="color: #66cc66;">&#40;</span>0xffffff<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// I personally prefer to set vars for repetitive values</span>
		<span style="color: #000000; font-weight: bold;">var</span> cubeSize:uint = <span style="color: #cc66cc;">240</span>;
		_cube = <span style="color: #000000; font-weight: bold;">new</span> Cube<span style="color: #66cc66;">&#40;</span>material, cubeSize, cubeSize, cubeSize<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// add the 3D elements to the stage</span>
		_view3D = <span style="color: #000000; font-weight: bold;">new</span> View3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		_view3D.<span style="color: #006600;">scene</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>_cube<span style="color: #66cc66;">&#41;</span>;
		addChild<span style="color: #66cc66;">&#40;</span>_view3D<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// add a listener so it becomes possible to render the 3D world</span>
		addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ PRIVATE METHODS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addedToStageHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, addedToStageHandler<span style="color: #66cc66;">&#41;</span>;
		init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span>event:Event<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;">// render the 3D world</span>
		_view3D.<span style="color: #006600;">render</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
</blockquote>
<p>With this code, this is what you should get as a result:</p>
<p><img class="aligncenter" title="Away3D cube with ColorMaterial applied" src="http://jansensan.net/images/blog/post0027_002.jpg" alt="Away3D cube with ColorMaterial applied" width="640" height="360" /></p>
<p>Not exactly exciting. For one, a <code>ColorMaterial</code> is really a flat color, so the best way to make it live a bit is adding light elements, which we will not see in this post (and that's also because I have not learned that yet). Also, we only see once face of the cube, quite boring.</p>
<p>To at least view that this object is in 3D, simply update the enterFrameHandler function.</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span>event:Event<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;">// increment the cube's rotation values to see its different sides</span>
	_cube.<span style="color: #006600;">rotationX</span>++;
	_cube.<span style="color: #006600;">rotationY</span>++;
	_cube.<span style="color: #006600;">rotationZ</span>++;
&nbsp;
	<span style="color: #808080; font-style: italic;">// render the 3D world</span>
	_view3D.<span style="color: #006600;">render</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
</blockquote>
<p><strong>Apply an image texture</strong></p>
<p>Most probably, you would like to add your own textures to your 3D elements. This is where it gets fun!</p>
<p>As suggested by a lot of users on the Away3D forums, it may be better to have a 3D artist create objects in <a title="Blender" href="http://www.blender.org/" target="_blank">Blender</a> or <a title="3ds Max" href="http://usa.autodesk.com/3ds-max/" target="_blank">3ds Max</a> (I do not know if <a title="Unity3D" href="http://unity3d.com/" target="_blank">Unity3D</a> can be used, although I hope it can). Once those objects are created, there is a way to import/load them into Away3D.</p>
<p>But in this case, since I do not know 3D software and because there is no need yet to get into complicated texture mapping, we are looking at something super simple: put an image on a cube. Most of what follows is a comprehensive summary of a <a title="Away3D Forum Need help understanding texture mapping" href="http://away3d.com/forum/viewthread/476/" target="_blank">thread</a> that followed my question on <a title="Away3D's forum" href="http://away3d.com/forum/" target="_blank">Away3D's forum</a>.</p>
<p>First things first: let's create an image. There are specifications to follow when creating an image for a <code>BitmapMaterial</code>.</p>
<p>A texture does not need to be square, however the dimensions have to be a power of two. What this means, is a texture can be 512 x 512 pixels, or 256 x 1024 pixels, etc. I worked with 2048 x 1024 pixels in this case.</p>
<p>Keep in mind that if you image is not square, it will not <a title="Wikipedia - Mipmap" href="http://en.wikipedia.org/wiki/Mipmap" target="_blank">mipmap</a>. Not fully convinced I understand what it means, as I do now know 3D vocabulary that much, but suffice to say you simply need to set <code>BitmapMaterial.mipmap</code> to <code>false</code> to make it work.</p>
<p>In the case of a cube, you need to cover all six sides. In order to do so, split your image into a 3 x 2 grid, like so:</p>
<p><img class="aligncenter" title="Dice texture" src="http://jansensan.net/images/blog/post0027_003.png" alt="Dice texture" width="640" height="320" /></p>
<p>Do you notice that each part of the image that represents a side of the cube is not square? It does not matter really, since Away3D will map it as a square onto the cube. As long as you respect the grid in your design, it will be good.</p>
<p>Rather than loading the image and in order to make things quicker, I simply <a title="Embedding Resources with AS3" href="http://www.bit-101.com/blog/?p=853" target="_blank">embedded</a> it in the code.</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript">package
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">containers</span>.<span style="color: #006600;">View3D</span>;
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">materials</span>.<span style="color: #006600;">BitmapMaterial</span>;
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">primitives</span>.<span style="color: #006600;">Cube</span>;
&nbsp;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageAlign</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageScaleMode</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span>frameRate=<span style="color: #ff0000;">&quot;60&quot;</span>, <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#ffffff&quot;</span>, <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;640&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;360&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ CONSTANTS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">&quot;../assets/images/dice-texture-2048x1024.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ImageClass:<span style="color: #000000; font-weight: bold;">Class</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ VARS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span>	<span style="color: #000000; font-weight: bold;">var</span>	_view3D		:View3D;
	<span style="color: #0066CC;">private</span>	<span style="color: #000000; font-weight: bold;">var</span>	_cube		:Cube;
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ CONSTRUCTOR ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<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: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		initStage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, addedToStageHangler<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ PRIVATE METHODS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initStage<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: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
		<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<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: #808080; font-style: italic;">// create a Bitmap from the embedded image</span>
		<span style="color: #000000; font-weight: bold;">var</span> image:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> ImageClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as Bitmap;
&nbsp;
		<span style="color: #808080; font-style: italic;">// create the BitmapMaterial</span>
		<span style="color: #000000; font-weight: bold;">var</span> material:BitmapMaterial = <span style="color: #000000; font-weight: bold;">new</span> BitmapMaterial<span style="color: #66cc66;">&#40;</span>image.<span style="color: #006600;">bitmapData</span><span style="color: #66cc66;">&#41;</span>;
		material.<span style="color: #006600;">smooth</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #808080; font-style: italic;">// little trick: you do not need to care if the image is square,</span>
		<span style="color: #808080; font-style: italic;">// simply evaluate if the sides are even</span>
		material.<span style="color: #006600;">mipmap</span> = <span style="color: #66cc66;">&#40;</span>image.<span style="color: #0066CC;">width</span> == image.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// create the cube</span>
		<span style="color: #000000; font-weight: bold;">var</span> cubeSize:uint = <span style="color: #cc66cc;">240</span>;
		_cube = <span style="color: #000000; font-weight: bold;">new</span> Cube<span style="color: #66cc66;">&#40;</span>material, cubeSize, cubeSize, cubeSize<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// add the 3D elements to the stage</span>
		_view3D = <span style="color: #000000; font-weight: bold;">new</span> View3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		_view3D.<span style="color: #006600;">scene</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>_cube<span style="color: #66cc66;">&#41;</span>;
		addChild<span style="color: #66cc66;">&#40;</span>_view3D<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// add a listener so it becomes possible to render the 3D world</span>
		addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
	<span style="color: #808080; font-style: italic;">//		[ PRIVATE METHODS ]</span>
	<span style="color: #808080; font-style: italic;">// + ----------------------------------------</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addedToStageHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, addedToStageHandler<span style="color: #66cc66;">&#41;</span>;
		init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span>event:Event<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;">// increment the cube's rotation values to see its different sides</span>
		_cube.<span style="color: #006600;">rotationX</span>++;
		_cube.<span style="color: #006600;">rotationY</span>++;
		_cube.<span style="color: #006600;">rotationZ</span>++;
&nbsp;
		<span style="color: #808080; font-style: italic;">// render the 3D world</span>
		_view3D.<span style="color: #006600;">render</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
</blockquote>
<p><strong>Fix the Away3D sources</strong></p>
<p>Now, I ran into an issue when <a title="Away3D Cube Test 01" href="http://jansensan.net/experiments/away3d-tests/cube01.html" target="_blank">I originally tested this</a> (Flash Player 11+ needed, click and drag to move the cube):</p>
<p><img class="aligncenter" title="Cube texture issue" src="http://jansensan.net/images/blog/post0027_004.jpg" alt="Cube texture issue" width="640" height="160" /></p>
<p>Some sides were repeated or not applied properly. That is actually what prompted me to ask my question on the forum, as I thought I had done everything proper.</p>
<p>I actually did, but here also, there was a correction needed in the Away3D sources. Away3d forum member <a title="80prozent" href="http://away3d.com/forum/member/992/" target="_blank">80prozent</a> posted a fix.</p>
<p>Look at the function <code>Cube.buildUVs()</code> into the <code>away3d.primitives.Cube class</code> and replace this part:</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; i &amp;lt;= _segmentsW; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	outer_uv = u_tile_step + u_tile_dim * <span style="color: #66cc66;">&#40;</span>i / _segmentsW<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j = <span style="color: #cc66cc;">0</span>; j &amp;lt;= _segmentsD; j++<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - v_tile_dim * <span style="color: #66cc66;">&#40;</span>j / _segmentsD<span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span>j / _segmentsD<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</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 &amp;lt;= _segmentsH; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	outer_uv = v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span>i / _segmentsW<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j = <span style="color: #cc66cc;">0</span>; j &amp;lt;= _segmentsD; j++<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>u_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsD - j<span style="color: #66cc66;">&#41;</span> / _segmentsD<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - <span style="color: #66cc66;">&#40;</span>u_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsD - j<span style="color: #66cc66;">&#41;</span> / _segmentsD<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsW - i<span style="color: #66cc66;">&#41;</span> / _segmentsW<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">target</span>.<span style="color: #006600;">updateUVData</span><span style="color: #66cc66;">&#40;</span>uvData<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>with this part:</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; i &amp;lt;= _segmentsW; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	outer_uv = u_tile_step + u_tile_dim * <span style="color: #66cc66;">&#40;</span>i / _segmentsW<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j = <span style="color: #cc66cc;">0</span>; j &amp;lt;= _segmentsD; j++<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - v_tile_dim * <span style="color: #66cc66;">&#40;</span>j / _segmentsD<span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - <span style="color: #66cc66;">&#40;</span>v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span>j / _segmentsD<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</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 &amp;lt;= _segmentsH; i++<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	outer_uv = v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span>i / _segmentsW<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j = <span style="color: #cc66cc;">0</span>; j &amp;lt;= _segmentsD; j++<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>u_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsD - j<span style="color: #66cc66;">&#41;</span> / _segmentsD<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - outer_uv;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">1</span> - <span style="color: #66cc66;">&#40;</span>u_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsD - j<span style="color: #66cc66;">&#41;</span> / _segmentsD<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		uvData<span style="color: #66cc66;">&#91;</span>uidx++<span style="color: #66cc66;">&#93;</span> = v_tile_step + v_tile_dim * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_segmentsW - i<span style="color: #66cc66;">&#41;</span> / _segmentsW<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">target</span>.<span style="color: #006600;">updateUVData</span><span style="color: #66cc66;">&#40;</span>uvData<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>His fix corrects the way the image is applied to the cube. I guess this will be eventually fixed, but at the time of writing this post, the sources provided by Away3D still need that correction.</p>
<p>And there you go! From then you can have an awesomely decorated cube with the texture of your choice!</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/apply-a-texture-on-a-cube-in-away3d-4-0/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting up FDT for Away3D and Flash Player 11 (Beta)</title>
		<link>http://jansensan.net/setting-up-fdt-for-away3d-and-flash-player-11-beta</link>
		<comments>http://jansensan.net/setting-up-fdt-for-away3d-and-flash-player-11-beta#comments</comments>
		<pubDate>Fri, 12 Aug 2011 22:02:28 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[FDT]]></category>
		<category><![CDATA[Flash Player 11 Beta]]></category>
		<category><![CDATA[Molehill]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=655</guid>
		<description><![CDATA[
Recently I had been approached to develop an interface for a huge interactive wall. The company has its own engine, but the interface runs as a Flash Player piece within that environment. I am not talking about Scaleform, which allows game developers to integrate interfaces built in AS3 into their projects, but the logic is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="FDT and Away3D" src="http://jansensan.net/images/blog/post0026_001.jpg" alt="FDT and Away3D" width="640" height="160" /></p>
<p>Recently I had been approached to develop an interface for a huge interactive wall. The company has its own engine, but the interface runs as a Flash Player piece within that environment. I am not talking about <a title="Scaleform" href="http://www.scaleform.com/" target="_blank">Scaleform</a>, which allows game developers to integrate interfaces built in AS3 into their projects, but the logic is pretty much the same.</p>
<p>So the idea was to use some simple 3D shapes and let users interact with it via a touch screen. The project did not go through, however I had done some research on the latest Flash Player beta developments and the latest alpha release of Away3D. As expected, I had to do a lot of searches in Google, I cursed at my computer once or twice, but I did learn a lot. I think it would be nice to share my discoveries.</p>
<p><strong>Setting up FDT to publish onto Flash Player 11 Beta</strong></p>
<p>I have to say a lot of people wrote blog posts already on how to do that. Although their posts explained more on how to use the incubator version of Flash Player, it's pretty easy to do a parallel. I'll just list the steps here and provide the sources to my information further down.</p>
<ol>
<li>Get the latest available Flash Player debugger, Flex SDK and playerglobal.swc (by the way, since the IDE is now called Flash Builder, why is the SDK still called "Flex SDK " rather than "Flash SDK"?)</li>
<li>Uninstall whatever version of the player you have on your computer and install the latest one you have downloaded</li>
<li>Replace the playerglobal.swc in the SDK with the separate playerglobal.swc you have downloaded</li>
<li>Set up the SDK in FDT</li>
<li>When creating a new project, make sure to add the <code>-swfversion=13</code> compile argument (I hope this will be dropped when the release is no longer in beta)</li>
<li>In your HTML page, do not forget to set <code>wmode="direct"</code> so the rendering can be done on the GPU</li>
</ol>
<p>Now these steps are really well explained <a title="Targeting Flash Player 11 (Incubator Build) in FDT 4.2" href="http://www.swfgeek.net/2011/03/07/targeting-flash-player-11incubator-build-in-fdt-4-2/" target="_blank">here</a>, although since the release of the beta version (rather than the incubator version), it is no longer necessary to remove the flex.swc.</p>
<p>Now, all this is a bit of work to get running, and just recently, <a title="Get your FDT ready for Molehill" href="http://fdt.powerflasher.com/blog/2011/04/get-your-fdt-ready-for-molehill/" target="_blank">FDT released a template</a> that sets up a lot of that stuff already. This template includes the compiler argument and an HTML template that presets the <code>wmode</code>, it even includes the <a title="M2D" href="https://github.com/egreenfield/M2D" target="_blank">M2D library</a>, which is supposed to help creating 2D elements with the <code>Stage3D</code> API to enjoy the benefits of GPU rendering. Thanks guys! I guess now I want to look into creating templates.</p>
<p><strong>Setting up Away3D</strong></p>
<p><img class="alignleft" title="Away3D sources and libs" src="http://jansensan.net/images/blog/post0026_002.jpg" alt="Away3D sources and libs" width="264" height="140" /></p>
<p>I have been reading good comments here and there about <a title="Away3D" href="http://away3d.com/" target="_blank">Away3D</a>, and the running examples I have seen were quite convincing, so I decided to look into it. Getting started is quite simple.</p>
<ol>
<li>Download the <a title="Away3D downloads" href="http://away3d.com/download/" target="_blank">Away3D 4.0 alpha release</a></li>
<li>Add the provided source files to your classpath</li>
<li>Add the provided Apparat LZMA decoder library as well</li>
</ol>
<p>Logically, this should be it and you should be able to go, but nooo! Have you ever seen a development project work properly on the first try? Especially not a project that uses both an alpha release and a beta release! After a bit of research, I found <a title="How to get started with the Molehill API and Away3D 40.html" href="http://www.disturbmedia.com/wiki/How_to_get_started_with_the_Molehill_API_and_Away3D_40.html" target="_blank">an article on DisturbMedia's wiki</a> that basically explained the situation:</p>
<blockquote><p>Most errors come from AGALMiniAssembler.as. I'm not sure why, but I found that if I split the multiple classes nested in the single file into multiple files that fixes most of the errors. At the end of the process you should have 3 additional classes: Sampler, Register and OpCode.</p></blockquote>
<p>Once the split classes are added, some errors remain in the Away3D sources, however it is possible to compile an empty project at this point.</p>
<p>Next, you would expect to be able to use some Away3D classes already, so did I. The base requirement is to add a <code>View3D</code>, which contains a container that can be used as some sort of stage. Let's try:</p>
<p>ActionScript 3.0:</p>
<blockquote>
<pre class="actionscript">package
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> away3d.<span style="color: #006600;">containers</span>.<span style="color: #006600;">View3D</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageAlign</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageScaleMode</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">private</span>	<span style="color: #000000; font-weight: bold;">var</span>	_view3D	:View3D;
&nbsp;
<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: #808080; font-style: italic;">// set the stage</span>
	<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
	<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// create the View3D</span>
	_view3D = <span style="color: #000000; font-weight: bold;">new</span> View3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	addChild<span style="color: #66cc66;">&#40;</span>_view3D<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//</span>
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span>event:Event<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;">// render the View3D at every frame (or other update of your choice)</span>
	_view3D.<span style="color: #006600;">render</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
</blockquote>
<p>Try and run that with the explanations I have given so far, you'll most probably run into the same situation I did: an error. Why? I mean, nothing seems wrong.</p>
<p>Here again, it took me a bit of research, but it turns out that <a title="Temp Fix for Stage3D.viewPort change, Flash 11 Beta" href="http://away3d.com/forum/viewthread/267/" target="_blank">a class needed a correction</a> to handle a change made by the beta release of Flash Player. As I understand, this library was mostly written while the player was still an incubator release. Simply get that updated <code>Stage3DProxy</code> class with the one provided in the forum thread, and you're good to go.</p>
<p>From this point on, you can head to minute 2:30 of <a title="Quickstart for Molehill and Away3D" href="http://johnlindquist.com/2011/02/28/quickstart-for-molehill-and-away3d/" target="_blank">John Lindquist's tutorial</a> to see how to add an awesome cube to your project, or look into the <a title="Away3D Broomstick Examples" href="https://github.com/away3d/away3d-examples-broomstick" target="_blank">Away3D examples</a>. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/setting-up-fdt-for-away3d-and-flash-player-11-beta/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Post Mortem: The ToDo List</title>
		<link>http://jansensan.net/post-mortem-the-todo-list</link>
		<comments>http://jansensan.net/post-mortem-the-todo-list#comments</comments>
		<pubDate>Thu, 28 Jul 2011 21:16:33 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Personal Works]]></category>
		<category><![CDATA[Post Mortem]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=535</guid>
		<description><![CDATA[
So here it is, the personal project I mentioned a while back: the ToDo List. Doing personal projects, without the constraints of client requests and deadlines is loads of fun, but also not always efficient. Let's have a look at the lessons I learned during this project.
What is the ToDo List?
The idea for this Facebook [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="The ToDo List" src="http://the-todo-list.com/assets/images/todo_list_logo_gray.png" alt="The ToDo List" width="360" height="80" /></p>
<p>So here it is, the personal project I mentioned a while back: <a title="The ToDo List" href="http://the-todo-list.com/" target="_blank">the ToDo List</a>. Doing personal projects, without the constraints of client requests and deadlines is loads of fun, but also not always efficient. Let's have a look at the lessons I learned during this project.</p>
<p><strong>What is the ToDo List?</strong></p>
<p>The idea for this Facebook application came from a discussion with art director <a title="Max Chanan" href="http://www.maxchanan.com/" target="_blank">Max Chanan</a>. We were thinking that there are always people in your Facebook friends that are not exactly your friends, but more acquaintances. However, it may also happen that you added said acquaintances to your Facebook contacts solely in the hopes of getting with them. Let's face it, either we ourselves have spied upon friends of friends that we think are hot, or we know someone who has.</p>
<p>And then I built the ToDo List, which allows you to select friends that you would like to do–pun totally intended.</p>
<p><img class="aligncenter" title="The ToDo List" src="http://jansensan.net/images/blog/post0025_001.jpg" alt="The ToDo List" width="640" height="464" /></p>
<p>The application, which currently resides on a Facebook app page, allows users to select up to four of their friends. That list stays secret, it is not shared with anyone else.</p>
<p>Secrecy is of the utmost importance in this project. How creeped out would a girl be if suddenly she received notifications that some five boys put her on a list of girls they would like to do? I can bet that she would be very upset.</p>
<p>But then, how does it work?</p>
<p>Well, let's say:</p>
<ul>
<li>Boy A selects girls A, B and C</li>
<li>Girl A does not use the ToDo List</li>
<li>Girl B uses the app, but has not selected boy A</li>
<li>Girl C uses the app and has selected boy A</li>
</ul>
<p>In the case of girl A, nothing will happen. In the case of girl B, nothing will happen either, because she did not select boy A. As we can see however, boy A and girl C mutually chose each other, this is where the magic happens.</p>
<p>On every Thursday of the week, a check is made to see who has selected who. If a match is made, then both users received an email notification informing them that they have been chosen by one of their choices.</p>
<p><img class="aligncenter" title="Match email" src="http://jansensan.net/images/blog/post0025_003.jpg" alt="Match email" width="640" height="184" /></p>
<p>Why Thursday and not instantly? Well, first of all, I like to think of this app almost like a poker game. You bet that these people you have selected may have selected you back. This list is like your hand. If at the deadline, on Thursday, your hand is not a winning one, you can change your selection for next round, on the followig Thursday.</p>
<p>When I was discussing with <a title="Martin Gauthier on Twitter" href="http://twitter.com/martingauthier" target="_blank">Martin Gauthier</a> about this app, he thought of something brilliant: In this world where everyone wants instant gratification, it's nice to have a bit of wait and anticipation before you see if you win or lose.</p>
<p><strong>Choosing a technology</strong></p>
<p>Having built a couple of projects in Flash, I thought at first that I would build this one in Flash too. When I was working on the Swarovski's Reflect Yourself Facebook app, I learned a bit on how to communicate with the Facebook API in AS3. But as usual, Facebook changed their API and did not document it clearly. I was tangled in too many different versions of both the <a title="Facebook AS3 API" href="http://code.google.com/p/facebook-actionscript-api/" target="_blank">Facebook AS3 API</a>, Flash was not right for this project.</p>
<p>Basically, what one needs to communicate with Facebook is an authorization from the user to sift through a certain amount of information. Once the user has authorized your apps with a certain amount of rights, there is a token that is created, and this token has to be provided in the calls to the Facebook API.</p>
<p>Facebook has a PHP API, so I started looking into this. I tried and failed at doing simple calls, like retrieving friends, but I did manage to get the token.</p>
<p>By then, Facebook had developed the <a title="Facebook Graph API" href="http://developers.facebook.com/docs/reference/api/" target="_blank">Graph API</a>, making things a lot, wait, A LOT simpler. A call to the Graph API is basically just a URL that returns a <a title="JSON" href="http://www.json.org/" target="_blank">JSON</a> object.</p>
<p>From then, I thought of a simple workflow:</p>
<ol>
<li>Get the user to authorize the app</li>
<li>Use the Facebook PHP library to get a session and a token</li>
<li>Make all other calls to the Facebook API using jQuery to <a title="jQuery Documentation - get" href="http://api.jquery.com/jQuery.get/" target="_blank">get</a> the data</li>
</ol>
<p>The project then became fun to do! A healthy mix of contemporary web techs, no plugin necessary. It's pretty nice, especially since I needed scrollbars and buttons, so they can then use the native browser interface and feel like they fit in Facebook.</p>
<p>It also means this works on mobile, although that is just a happy accident. The project is not optimized one bit for mobile. More on that later.</p>
<p><strong>Discoveries</strong></p>
<p>So obviously, I did some technical discoveries, but also some strategy- and PR-related discoveries. It may seem obvious to a lot of us (I even have spoken to that effect <a title="Simple share functionality for multiple=">previously</a>), but word of mouth is not easy! It's almost impossible to make your project grow when you count only on the social networks like Facebook and Twitter. Without publicity, people don't go to your website.</p>
<p>Now, it would be unfair to say that I had no publicity whatsoever. Let's not get confused, it is a personal project, through and through, but I built it as I was still working at <a title="Sid Lee" href="http://www.sidlee.com/" target="_blank">Sid Lee</a>. As such, <a title="Jean-François Bouchard on Twitter" href="http://twitter.com/jfbouchard" target="_blank">Jean-François Bouchard</a>, president of the agency, offered me to talk about the project on the platforms to which he has access if I simply branded it as a "Sid Lee Collective" project. Sid Lee sometimes encourage their employees to work on personal projects. They may support it financially or by other means if they find said project interesting. In my case, I did not need any financial support, but I gladly accepted the simple branding since it allowed me some visibility.</p>
<p style="text-align: center; margin-bottom: 16px;"><img title="Sid Lee's Facebook post about the ToDo List" src="http://jansensan.net/images/blog/post0025_006.jpg" alt="Sid Lee's Facebook post about the ToDo List" width="344" height="602" /></p>
<p>So such a public support indeed provided me with a lot of visitors onto the project, which is awesome. From then on though, I should have found a way to continually bring new visitors, but I did not, and this is what the analytics show.</p>
<p style="text-align: center;"><img title="Three months on Google Analytics" src="http://jansensan.net/images/blog/post0025_005.jpg" alt="Three months on Google Analytics" width="640" height="145" /></p>
<p>Something surprised me: even with all those visitors, not a lot of people dared to use the app. Is it because they do not trust a Facebook app? Is it because the subject matter is too racy? I'm not sure I will know. I did end up in an interesting debate with <a title="Christelle Samson on Twitter" href="http://twitter.com/christ_elle" target="_blank">Christelle Samson</a> about how legitimate is this app for people who are in a relationship. My take stays that if people want to cheat on their "loved" one, tools are not to blame.</p>
<p>Another user asked me a good question: will the app post anything on his profile? As said earlier, secrecy is of the utmost importance with this app. However, when one starts to use a Facebook app, a post is necessarily placed on the user's wall saying that he started using that app. Last I checked, it was not something that the developer could set to not happen.</p>
<p>Overall, the app has relatively the same amount of users (some 300) and matches (some 30 matches every week) since the start. This leads me to believe that people are not really adventurous, most of them probably selected their girlfriends or boyfriend, and did not change their list since.</p>
<p><strong>Future iterations</strong></p>
<p>Even though there is no imperative to do so, I want to move the app out of its Facebook placeholder and onto its own domain, which I already own anyways. I think that design wise and user experience wise, this will be better. The functionalities will stay the same, but it will feel less as a page living under Facebook and more like a real web app.</p>
<p>However, moving the app onto the domain is not the most interesting project I have. I have recently started following Objective-C tutorials, and I think that this app could be quite interesting, if not more appealing, if there was an iOS app for it. So I started mocking up the information architecture. You can expect me to eventually post more info about this.</p>
<p><strong><img class="aligncenter" title="Notes for the ToDo List iPhone app" src="http://jansensan.net/images/blog/post0025_004.jpg" alt="Notes for the ToDo List iPhone app" width="640" height="480" /></strong></p>
<p><strong>Conclusion</strong></p>
<p>After three months, I see that this project needs more support if I want to make it live. The iOS app and the website are a good step in that direction I believe. It would be awesome if I could eventually sell this to some online dating company. For now, I still take this project as a lab to learn more techs.</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/post-mortem-the-todo-list/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book review: Flash game development by example</title>
		<link>http://jansensan.net/book-review-flash-game-development-by-example</link>
		<comments>http://jansensan.net/book-review-flash-game-development-by-example#comments</comments>
		<pubDate>Sun, 05 Jun 2011 19:05:59 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Emanuele Feronato]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=576</guid>
		<description><![CDATA[
Thanks to Antti Kupila, I have been given a copy of Emanuele Feronato's book Flash Game Development by Example to read and critique. Emanuele has been blogging about Flash gaming for years, and since I am looking to get into gaming, I was eager to read the book.
So far I have made it only through [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" title="Flash Game Development by Example, the book" src="http://jansensan.net/images/blog/post0024_001.jpg" alt="Flash Game Development by Example, the book" width="640" height="360" /></p>
<p>Thanks to <a href="http://www.anttikupila.com/">Antti Kupila</a>, I have been given a copy of <a href="http://www.emanueleferonato.com/">Emanuele Feronato</a>'s book Flash Game Development by Example to read and critique. Emanuele has been blogging about Flash gaming for years, and since I am looking to get into gaming, I was eager to read the book.</p>
<p>So far I have made it only through the first three chapters. I did a preliminary critique of the book on the <a href="http://www.amazon.com/Flash-Development-Example-Emanuele-Feronato/dp/1849690901/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1307018451&amp;sr=1-1">Amazon product page</a>:</p>
<blockquote><p>Emanuele Feronato has been blogging ([...]) good tips on Flash gaming and PHP development for a while now. When I learned he had written a book on how to get into game development, I had to try it.</p>
<p>In line with his blog, Feronato's writing is clear and concise, no fluff is added. A good thing is that he assumes the reader has already some knowledge of Flash and AS3. This book does present some basic information if you know nothing of Flash, but the intent of this book is to teach you how to do games, not how to program. This is really a good thing, for there are way too many books that think that all readers have never touched programming of their life.</p>
<p>Feronato does a good job at increasing the difficulty of concepts during each chapter. His introduction to each challenge, by splitting the concept and the coding, guides the reader properly.</p>
<p>As a web developer, jumping into gaming is a good and honest challenge. Oftentimes a web dev tends to create complex systems for data and views. Feronato brings back the joy of programming with simple and logic code structures.</p>
<p>I did get put off by the fact that his instructions make use of the Flash IDE, rather than Flash Builder, FDT or FlashDevelop. In a professional environment, it's quite inefficient to code in the Flash IDE, but I believe it would have taken too many explanations to put in a book about games. All in all, it is quite easy to transpose the instructions into code-only IDEs.</p>
<p>I would also have like some more game-oriented optimization tips (like using multiplications rather than divisions, since it is quicker), for gaming is all about being code-efficient. That said, it is a good buy for those who are serious about getting into Flash gaming.</p></blockquote>
<p>I have read the other critiques of the book on Amazon and also other critiques from real game devs like <a href="http://blog.iainlobb.com/2011/05/flash-game-development-by-example-book.html">Iain Lobb</a> and <a href="http://gamedev.rasmuswriedtlarsen.com/2011/05/31/review-flash-game-development-by-example/">Rasmus Wriedt Larsen</a> and it got me thinking.</p>
<p><strong>Critiquing the critique</strong></p>
<p>My grandad used to say: "Only a fool does not change his mind." Whereas I do not think as harshly about the book, I do want to delve deeper into my critique to either correct what I said, or even add to it.</p>
<p>Lobb mentions the coding style of Feronato, which I also noted looks a lot like PHP's style:</p>
<blockquote><p>We all write weird looking code sometimes, but I think a book needs to set a better example.</p></blockquote>
<p>I must say that it did not deter me really too much, since I am used to pick up other people's work and fix it. However, now that I think of it, a book must set an example of good coding practices. I have to agree with Lobb on his critique.</p>
<p>Another practice that really should have been present in Feronato's code is tips that make code execute faster.</p>
<p>Using <code>var array:Array = []</code> may look dirty, but it is way quicker than creating arrays with the <code>new Array()</code> declaration. His examples do not use many arrays, but I do not see why good habits should not be put forward.</p>
<p>Another tip is to try and use multiplications rather than divisions. Again, the examples do not use calculations that are processor intensive, but it is the best moment to explain to new game developers tips that will help them when they have to handle complex systems in the future.</p>
<p>But those tips are something that I knew already and that could have been used in the first three chapters of the book. Let's see when I get further in the book how it goes.</p>
<p>Both Lobb and Larsen look onto Feronato's code as merely scripts, for it doesn't push OOP concepts. As Feronato's book is really built on iterating his code and moving it forward, as many oftentimes code in real life, it would have been nice for him to explain how to transform hid code into classes etc. The speed at which Feronato moves through concepts means the reader is  expected to know how to code. And if so, the reader could also then be  expected to know some OOP. Feronato could have used such a premise to  then push the use of classes. Unknowingly, I worked exactly how Larsen describes what he sees in his book:</p>
<blockquote><p>[...] if you know how to code AS3 with OOP and good coding practises, plus  being able to extract general ways of doing something from very specific  examples [...]</p></blockquote>
<p>As I mentioned in my Amazon critique, I would have preferred it if the  author would have not used the Flash IDE to code, since it's pretty  backwards. As I was going through his examples, I actually used FDT to create a proper project structure, with assets, packages and different classes for specific tasks.</p>
<p>I did enjoy Feronato's scripting style to read, but I do now think the book he wrote should have promoted practices that would be useful in professional environments.</p>
<p>Lobb critiques Feronato's choices of games for being out of touch with current trends. He makes an interesting point:</p>
<blockquote><p>I really think that a lot of game developers around my age group (e.g.  25 and older) are stuck in the past somewhat with their ideas of what  constitutes a computer game.</p></blockquote>
<p>I think that using a lot of pixel sprites in my prototypes casts me in that group. However I must disagree with Lobb here. I am not fan of Flip and Match games, Tetris or other classic puzzlers per se. As good a developer I am, I have never tackled a real game project. Starting from scratch with basic concepts and logics actually helps me learn things properly.</p>
<p>For example, in Minesweeper, the logic of how to use and create a <a title="Wikipedia - Flood Fill" href="http://en.wikipedia.org/wiki/Flood_fill" target="_blank">flood fill</a> function is explained. Since I come from a web development, where the UI is usually the most important concern, I would not know what to call such a concept. It is a definite win for me here.</p>
<p>Another example is the Connect Four winning explanations. Feronato explains how a win is made in concepts and how to translate that in code. I know pseudo code is not something new in development, but learning to do it for gaming is, to me and maybe to other non-gaming developers, something refreshing and useful.</p>
<p>Let's take a look at what I was able to create with what I have read so far.</p>
<p><strong>Concentration, a flip and match game</strong></p>
<p>This game is pretty straightforward, we pretty much all know it. Feronato explains in simple terms how to build such a game.</p>
<p>What  is missing however is an explanation for the reader on how to reset the  game so the player can enjoy more than one game. Actually, the author  does not explain how to restart any of the games he describes. That is a  big part in gaming, it should be present in his book I believe. It  would also have been a great way to show how to use functions. So as you  can see from my prototype above, I have added that logic. Once the game  is complete, the user can retry to play.</p>
<p>Stats on how the game  progresses is also interesting for the player to see. Lobb actually  mentions this in his critique, although I had though of adding these  stats previous to reading the article.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="FlashVars" value="scale=2" /><param name="src" value="http://jansensan.net/experiments/game-dev-concentration/swf/concentration.swf" /><param name="flashvars" value="scale=2" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://jansensan.net/experiments/game-dev-concentration/swf/concentration.swf" flashvars="scale=2"></embed></object></p>
<p>As a personal touch, I decided to make my game shareable on Facebook's wall so that my friends could try that little prototype in their news stream. I will eventually explain how easy that is, but it is not the point of this blog post. You may try it yourself in sharing the URL http://jansensan.net/experiments/game-dev-concentration/ onto your news stream. Do not just copy the URL into your browser, it redirects to this post.</p>
<p>Once you share the above URL onto your news stream, it will then show like this:</p>
<p style="text-align: center;"><img class="alignnone" title="Flip and Match in Facebook news stream" src="http://jansensan.net/images/blog/post0024_002.jpg" alt="Flip and Match in Facebook news stream" width="431" height="164" /></p>
<p>If you ever used YouTube or Vimeo on your news stream, you know the Flash piece will expand when they click on the blue play button.</p>
<p style="text-align: center;"><img class="alignnone" title="Flip and Match in Facebook news stream" src="http://jansensan.net/images/blog/post0024_003.jpg" alt="Flip and Match in Facebook news stream" width="458" height="444" /></p>
<p>With those simple additions, people were enjoying a simple prototype and sharing it around.</p>
<p><strong>Minesweeper</strong></p>
<p>To be honest, I never understood the Minesweeper game, or rather what  is compelling to play it. Or maybe I just hate it because that is the  only game that was available on my dad's work computer at the government  when I was visiting and he was asking me to wait for him... Anyways, I  digress...</p>
<p>Feronato only explains what makes the player lose the game, however he should also have explained what is the win situation. An author cannot take for granted that the reader knows the game that is described.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="480" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://jansensan.net/experiments/game-dev-minesweeper/swf/minesweeper.swf" /><embed type="application/x-shockwave-flash" width="640" height="480" src="http://jansensan.net/experiments/game-dev-minesweeper/swf/minesweeper.swf"></embed></object></p>
<p>With this game, Feronato explains some recursion and the concept of the flood fill, which I believe is well worth to learn.</p>
<p>Concerning the use of functions however, the explanations lack. Functions are made to reuse code and, again, restarting a game is the perfect need to reuse code. As you can see from the prototype, you can only play once, which as I mentioned before is not a way to build a complete game.</p>
<p>Maybe I have not read enough tech books, but whenever I stumble upon an example online that uses events, the tutorial not always explains that it is best to remove the event handlers, sometimes even in Adobe's documentation! Many a time did I have to explain or correct other people's code to reduce the demand on memory. Feronato does explain to remove the event handler, I have to give him props for this.</p>
<p><strong>Connect Four</strong></p>
<p>This game is not digital by any means, and recreating it does not make it more fun. However, the logic learning with this game is quite nice. Games like <a title="Drop 7 for iOS" href="http://itunes.apple.com/us/app/drop7/id299940763?mt=8" target="_blank">Drop 7</a> seems to be a game that extrapolates on the concepts defined in Connect Four.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://jansensan.net/experiments/game-dev-connect-four/swf/connect-four.swf" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://jansensan.net/experiments/game-dev-connect-four/swf/connect-four.swf"></embed></object></p>
<p>The structure of the code in this game made me cringe. I believe that under no circumstance should a child tell its parent what to do. Sounds logical no? I mean not only about code, just read the previous sentence aloud and you will feel how much sense it makes.</p>
<p>Feronato actually does that here, he write something like <code>this.parent.parent</code>. It is not technically wrong, since it compiles, but I believe that conceptually it is not right. It makes it so complex for someone else to inherit a project and try to figure out such a logic. Big no-no.</p>
<p>While explaining how to check for the game completion, the author does bring forward the idea that is it not efficient to loop through all possible tiles. Good suggestion on code efficiency here.</p>
<p><strong>So, what now?</strong></p>
<p>I do see that this book has some flaws, but nothing that could not have been corrected or pushed more. I think also however that both Larsen and Lobb have dismissed a couple of things in their critique.</p>
<p>a) The audience. Larsen makes a good point that the code is quick and dirty and that the prototypes are not teaching concepts, but that is exactly what the introduction says:</p>
<blockquote><p>Who this book is for</p>
<ul>
<li>AS3 developers who want to know quick and dirty techniques to create Flash games</li>
<li>Flash animators who want to learn how to create games from their works with AS3</li>
<li>Programmers who know languages different than AS3 and want to learn AS3 to make something more interesting and fun than the old "phone book"</li>
<li>Even if you aren't a programmer, but you love Flash games, you can count on this book: you will be guided step by step with clear examples and the support of the full source code of every game</li>
</ul>
</blockquote>
<p>Now, is that audience right? That's another question, but it is clearly stated.</p>
<p>b) The types of game. Lobb did hit on that and I do what to bring it back. The title of the book clearly states that is for building classic games, mostly puzzlers.</p>
<blockquote><p>Build 9 classic Flash games and learn game development along the way</p></blockquote>
<p>Again, the question to raise is, is that a good thing to teach devs? With Stage3d (a.k.a. Molehill), P2P, game controllers on AIR and all sorts of awesome features, Flash can be so much more as a gaming platform.</p>
<p>All in all, I will go on reading the book, for I know I will learn some more things. I agree however that this book does not feel complete, but it feels like a good primer to get into game development. Hey, I may also be wrong, but once a reader knows about some concepts like AI, recursion, etc., it then becomes more possible to search for more precise concepts.</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/book-review-flash-game-development-by-example/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Leaving Sid Lee</title>
		<link>http://jansensan.net/leaving-sid-lee</link>
		<comments>http://jansensan.net/leaving-sid-lee#comments</comments>
		<pubDate>Mon, 09 May 2011 08:36:12 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Commercial Works]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Personal Works]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Sid Lee]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=533</guid>
		<description><![CDATA[
So this is it. After some three years working with Sid Lee I have decided to move on to other challenges. I was hired by Sid Lee in Montréal in spring some three years ago as an interactive developer. A year and a half later, I was transferred to the Amsterdam workshop where I eventually [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" src="http://jansensan.net/images/blog/post0023_001.jpg" title="Mat ♥ Sid" alt="Mat ♥ Sid" width="640" height="112" /></p>
<p>So this is it. After some three years working with <a href="http://sidlee.com" target="_blank">Sid Lee</a> I have decided to move on to other challenges. I was hired by Sid Lee in Montréal in spring some three years ago as an interactive developer. A year and a half later, I was transferred to the Amsterdam workshop where I eventually became one of the technical leads. I was part of the team that would provide technical council, brainstorm during creation and either assist or develop during production, depending on the needs and resources.</p>
<p>I would be lying if I did not say that I learned a great deal there. From advertising principles to dealing with many fields (strategy, design, accounting, etc.), I now understand the full creative flow from client requests to agency concepts to customer's view.</p>
<p>Sid Lee also put a lot of confidence in me in giving me a lot of cool projects. I hadn't been long with them that I was part of the creative team to redo their whole portfolio! I worked on beautiful projects such as Cirque du Soleil's Criss Angel's Believe website, the adidas Women's Lookbook SS10. Actually, most of <a href="http://jansensan.net/portfolio" target="_blank">my portfolio</a> currently consists of work done with Sid Lee.</p>
<p>There is also quite an awesome culture at Sid Lee, one I have never seen before. Never before had I been invited to a VP's house for a BBQ, never before could I share a random drink with a partner and talk shit about anything. The people that work there are amazing and talented, so much so that there is no way you can brag about your feats, since everybody rocks.</p>
<p><strong>Not everything is edible in the garden</strong></p>
<p><img class="aligncenter" src="http://jansensan.net/images/blog/post0023_002.jpg" title="Sid Lee's Green Room" alt="Sid Lee's Green Room" width="640" height="200" /></p>
<p style="font-size:10px; text-align: right;">Photo by <a href="http://anttikupila.com/" target="_blank">Antti Kupila</a></p>
<p>Just as in any position, there are awesome moments and awful moments working for Sid Lee. Sometimes, communication or workflows are broken, expectations from many parties are excessive or off. I will not rip them here, for it will serve no purpose and I do not hold a grudge against anyone there.</p>
<p>There is one thing I did expect however. As I was hired because I have a passion for tangible computing and installation arts, I thought I would have the time/be given the opportunity to suggest paths or explore these axes.</p>
<p>I have come to understand that clients fear experimental technologies or ideas. In the end, technological feats, experiments or artful pieces are not what clients want, but rather they want to simply leverage technology to sell more of their product.</p>
<p>Which is totally normal for them, but not for me. I need to explore, I need to learn, I need to play with things, with visuals, with the tangible. Maintenance or back end is not what I am interested in doing. I need to create and build, I need to see the results of what I am building.</p>
<p><strong>Will the grass really be greener on the other side?</strong></p>
<p><img class="aligncenter" src="http://jansensan.net/images/blog/post0023_003.jpg" title="The SoundPlant" alt="The SoundPlant" width="640" height="320" /></p>
<p>So I want to move on, but move on to what? For one thing, I would really like to steer away from the web. As I said earlier, clients simply want to drive their sales. Clients do not want to sell the interactive part, they want the interaction to convert users into customers.</p>
<p>Game development would be, for me, the next logical step. It may be a romantic idea, but I believe that in this field, the interaction IS what you want to sell. This may motivate me to push my boundaries and work.</p>
<p>I would also like to go back and try to build more tangible pieces. I have dabbled in the past with sensors connected to Arduinos, Max/MSP, room-sized installations, lights, speakers, etc. Dirtying my hands while building something that is not just virtual may be a good move too.</p>
<p>If at all possible, living off <a href="http://soundcloud.com/jansensan" target="_blank">my music</a> or musical skills would be the best. It has nothing to do with the content of this blog really, but it is still part of me, and a possible future path.</p>
<p><strong>Toil the soil and plant seeds</strong></p>
<p>So, all these ideas, but what now? Well, I am heading back home to Montréal in June and I actually plan to take all of summer off, as a sabbatical. I will play with some techs, read and try gaming logics and ideas, go back to the drawing board—both litteraly and figuratively.</p>
<p>When I went to Flash on the Beach, as <a href="http://jansensan.net/flash-on-the-beach-2010-the-aftermath">I mentionned before</a>, <a href="http://sagmeister.com/" target="_blank">Stefan Sagmeister</a>'s talk, <a href="http://www.ted.com/talks/stefan_sagmeister_the_power_of_time_off.html" target="_blank">The Power of Free Time</a>, had a great impact on me.</p>
<p style="text-align: center;"><!--copy and paste--><object width="446" height="326"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talks/dynamic/StefanSagmeister_2009G-medium.flv&su=http://images.ted.com/images/ted/tedindex/embed-posters/StefanSagmeister-2009G.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=649&lang=eng&introDuration=15330&adDuration=4000&postAdDuration=830&adKeys=talk=stefan_sagmeister_the_power_of_time_off;year=2009;theme=speaking_at_tedglobal2009;theme=art_unusual;theme=might_you_live_a_great_deal_longer;theme=what_makes_us_happy;theme=the_creative_spark;theme=unconventional_explanations;theme=not_business_as_usual;theme=tales_of_invention;event=Tales+of+Invention;tag=Design;tag=adventure;tag=art;tag=creativity;tag=happiness;tag=innovation;tag=work;&preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="446" height="326" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talks/dynamic/StefanSagmeister_2009G-medium.flv&su=http://images.ted.com/images/ted/tedindex/embed-posters/StefanSagmeister-2009G.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=649&lang=eng&introDuration=15330&adDuration=4000&postAdDuration=830&adKeys=talk=stefan_sagmeister_the_power_of_time_off;year=2009;theme=speaking_at_tedglobal2009;theme=art_unusual;theme=might_you_live_a_great_deal_longer;theme=what_makes_us_happy;theme=the_creative_spark;theme=unconventional_explanations;theme=not_business_as_usual;theme=tales_of_invention;event=Tales+of+Invention;tag=Design;tag=adventure;tag=art;tag=creativity;tag=happiness;tag=innovation;tag=work;"></embed></object></p>
<p>When I choose to get back to the world of the working, I will not return as a full time worker. I realize that now, I need time to balance work and creation. Akin to <a href="http://www.slate.com/id/2274736/" target="_blank">how many women do it in the Netherlands</a> by working either part time or not all, by choosing their personal life and emancipation before work.</p>
<p>I feel lucky that I stumbled upon that talk from Mike Monteiro, Design Director, and co-founder of <a href="http://www.muledesign.com/" target="_blank">Mule Design Studio</a>: <a href="http://vimeo.com/22053820" taget="_blank">Fuck You. Pay Me.</a></p>
<p style="text-align: center;"><object width="640" height="360"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=22053820&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=22053820&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="360"></embed></object></p>
<p>I understand he speaks in harsh words, but warnings like these may help me greatly when I decide to jump into the world of freelancing.</p>
<p>But will I freelance? If so, will it be in the web, in games, in installations? Would I go back to give tutorials on web technologies in colleges? Or maybe go down a more creative path? After all, it does not matter. <a href="http://twitter.com/iainlobb" target="_blank">Iain Lobb</a> retweeted <a href="http://twitter.com/mworch" target="_blank">Matthias Worch</a> recently, which totally comforted me in my choice of jumping into the unknown:</p>
<p><img class="aligncenter" title="Matthias Worch - Questioning your creative development?" src="http://jansensan.net/images/blog/post0023_004.jpg" alt="Matthias Worch - Questioning your creative development?" width="640" height="220" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/leaving-sid-lee/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple share functionality for multiple social networks</title>
		<link>http://jansensan.net/simple-share-functionality-for-multiple-social-networks</link>
		<comments>http://jansensan.net/simple-share-functionality-for-multiple-social-networks#comments</comments>
		<pubDate>Mon, 18 Apr 2011 10:29:11 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[RenRen]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[vKontakte]]></category>
		<category><![CDATA[ВКонтакте]]></category>
		<category><![CDATA[人人网]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=505</guid>
		<description><![CDATA[
	

Whether it's a game, a website, a video or even a subsection in these projects, it seems that they all need a share button. I personally believe it is sometimes too much, to the point that it seems that the PR and media teams avoid doing their work in the hopes that the customer/user will [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
	<img class="aligncenter" title="Social Networks Icons" src="http://jansensan.net/images/blog/post0022_001.jpg" alt="Social Networks Icons" width="640" height="126" />
</p>
<p>Whether it's a game, a website, a video or even a subsection in these projects, it seems that they all need a share button. I personally believe it is sometimes too much, to the point that it seems that the PR and media teams avoid doing their work in the hopes that the customer/user will spread the word for them. But that may be just me complaining again.</p>
<p>Nevertheless, I will present here how to use the simple sharing functionality of some of the most prominent social networks around. Remember that Facebook and Twitter are not king and queen everywhere, you may want to target your markets properly.</p>
<p>&nbsp;</p>
<p><img title="Facebook Icon" src="http://jansensan.net/images/icon-facebook.png" alt="Facebook Icon" width="16" height="16" /><strong>&nbsp;Facebook</strong></p>
<p>The infamous social network. As a developer, I kind of like to hate this network, for its documentation is poor and quickly outdated. On the other hand, if Facebook changes its API this often, it allows them to implement new stuff quicker.</p>
<p>Facebook has a relatively simple sharing functionality, even some additional info that you can put on your site metadata to display on the user's wall. I am not taking here about the Like button, which would display number of "likes"—although these <a title="Facebook Like Button Takes Over Share Button Functionality" href="http://mashable.com/2011/02/27/facebook-like-button-takes-over-share-button-functionality/" target="_blank">two functionalities were merged</a>.</p>
<p>In order to share, you do not need Facebook connect at all, you would only need it if your application, game or site requires access to the user's data. You simply need to call a URL:</p>
<blockquote>
<p>http://www.facebook.com/sharer.php?u=http://example.com&amp;t=The Post's Title</p>
</blockquote>
<p>If we deconstruct the URL, it's pretty easy to see what is what:</p>
<div>
<ul>
<li><strong>http://www.facebook.com/sharer.php</strong>: the URL to the PHP function that will share on Facebook</li>
<li><strong>u=http://example.com</strong>:<strong>u</strong> is the variable name which represents the URL that you want to share</li>
<li><strong>t=The Post's Title</strong>: <strong>t</strong> is the variable name which represents the title of what will be shared on the wall</li>
</ul>
</div>
<p>Keep in mind however that if the site that you share has a title and description metadata, the value that you set to <strong>t</strong> will be overwritten.</p>
<p>You may also want to push it further and set yourself the title, the description and even a thumbnail for your site. For example, this is what was done for the adidas Porsche Design site:</p>
<p style="text-align: center;">
<img class="alignnone" title="adidas Porsche Design sharing on Facebook" src="http://jansensan.net/images/blog/post0022_002.jpg" alt="adidas Porsche Design sharing on Facebook" width="640" height="583" />
</p>
<p>In order to set those values, simply add the Facebook metadata tags on the page you wish to share, like so:</p>
<p>HTML:</p>
<blockquote><p><code>&lt;meta property="og:title" content="Your website title goes here"/&gt;<br />
&lt;meta property="og:description" content="Your website description goes here"/&gt;<br />
&lt;meta property="og:image" content="http://www.dummyimage.com/50x50"/&gt;</code>
</p></blockquote>
<p>You may read more in the <a title="Facebook Doc - Like Button" href="http://developers.facebook.com/docs/reference/plugins/like/" target="_blank">Facebook documentation</a>. (I can't believe I just wrote that...)</p>
<p>&nbsp;</p>
<p><img title="Twitter Icon" src="http://jansensan.net/images/icon-twitter-2.png" alt="Twitter Icon" width="16" height="16" /><strong>&nbsp;Twitter</strong></p>
<p>The way to share on Twitter is pretty similar to Facebook's, if not simpler. Here as well, you may simply use a URL with some parameters:</p>
<blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco; color: #2a00ff} span.s1 {color: #000000} -->http://twitter.com/share?url=http://example.com&amp;text=This tweet has been shared via a URL.</p>
</blockquote>
<p>Here again, here is a breakdown of the URL:</p>
<div>
<ul>
<li><strong>http://twitter.com/share</strong>: the URL to the function that will share on Twitter</li>
<li><strong>url=http://example.com</strong>: <strong>url</strong> is the variable name which represents the URL that you want to share</li>
<li><strong>text=This tweet has been shared via a URL.</strong>: <strong>text</strong> is the variable name which contains the tweet</li>
</ul>
</div>
<p>&nbsp;</p>
<p><img title="LinkedIn Icon" src="http://jansensan.net/images/icon-linkedin.png" alt="LinkedIn Icon" width="16" height="16" /><strong>&nbsp;LinkedIn</strong></p>
<p>LinkedIn also offers a simple URL for sharing:</p>
<blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco; color: #2a00ff} span.s1 {color: #000000} -->http://www.linkedin.com/shareArticle?mini=true&url=http://example.com&title=The Post's Title</p>
</blockquote>
<p>Their share URL contains an additional parameter:</p>
<div>
<ul>
<li><strong>http://www.linkedin.com/shareArticle</strong>: the URL to the function that will share on LinkedIn</li>
<li><strong>mini=true</strong>: for some reason, the API requires this <strong>mini</strong> parameter to always be present and set to true.</li>
<li><strong>url=http://example.com</strong>:<strong>url</strong> is the variable name which represents the URL that you want to share</li>
<li><strong>title=The Post's Title</strong>: <strong>title</strong> is the variable name which represents the title of what will be shared</li>
</ul>
</div>
<p>LinkedIn provides <a href="http://developer.linkedin.com/docs/DOC-1075" target="_blank">well explained documentation</a> on how to use their sharing functionality. Although for the life of me I don't get why I would ever use the summary parameter.</p>
<p>&nbsp;</p>
<p><img title="ВКонтакте Icon" src="http://jansensan.net/images/icon-vkontakte.png" alt="ВКонтакте Icon" width="16" height="16" /><strong>&nbsp;ВКонтакте (vKontakte)</strong></p>
<p>ВКонтакте's share is <a href="http://vkontakte.ru/page-1_18900008" target="_blank">well documented</a>. Can't read Russian? Get <a href="http://www.google.com/chrome/" target="_blank">Google Chrome</a>, it translates websites quite well.</p>
<p>Even though there is a lot of options available for sharing, let's look at a simple share:</p>
<blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco; color: #2a00ff} span.s1 {color: #000000} -->http://vkontakte.ru/share.php?url=http://example.com&title=The Post's Title</p>
</blockquote>
<p>Pretty much the same as Facebook:</p>
<div>
<ul>
<li><strong>http://vkontakte.ru/share.php</strong>: the URL to the PHP function that will share</li>
<li><strong>url=http://example.com</strong>:<strong>url</strong> is the variable name which represents the URL that you want to share</li>
<li><strong>title=The Post's Title</strong>: <strong>title</strong> is the variable name which represents the title of what will be shared</li>
</ul>
</div>
<p>&nbsp;</p>
<p><img title="人人网 Icon" src="http://jansensan.net/images/icon-renren.png" alt="人人网 Icon" width="16" height="16" /><strong>&nbsp;人人网 (RenRen)</strong></p>
<p>We now enter the realm of assumptions, I simply relay information I found about how to share on RenRen. A user named <a href="https://forums.jigsy.com/showthread.php?tid=877" target="_blank">Yuao shared his knowledge</a>, and it seems that again, a simple URL with some parameters do the trick:</p>
<blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco; color: #2a00ff} span.s1 {color: #000000} -->http://share.renren.com/share/buttonshare.do?link=http://example.com&title=The Post's Title</p>
</blockquote>
<p>Let's see what that URL is made of:</p>
<div>
<ul>
<li><strong>http://share.renren.com/share/buttonshare.do</strong>: the URL to the function that will share on RenRen</li>
<li><strong>link=http://example.com</strong>: <strong>link</strong> is the variable name which represents the URL that you want to share</li>
<li><strong>title=The Post's Title</strong>: <strong>title</strong> is the variable name which represents the title of what will be shared</li>
</ul>
</div>
<p>Due to the documentation being all in Chinese, it's kind of hard to obtain more information. As far as I know, Google cannot sift through stuff in China easily. Also, the company itself did not want to provide help unless huge sums were paid upfront.</p>
<p>&nbsp;</p>
<p><strong>Other networks</strong></p>
<p>There are obviously other networks, but as you can see from the last one of which I spoke, my knowledge gets thin. <a href="http://hyves.nl/" target="_blank">Hyves</a>, <a href="http://www.orkut.com/" target="_blank">Orkut</a> and <a href="http://mixi.jp/" target="_blank">Mixi</a> may be of interest if your data shows that your users are part of such networks.</p>
<p>As for every project, make sure that implementing the sharing functionality makes sense. It may be obvious, but not all networks need to be targetted for every single project.</p>
<p>If you target multiple markets and social networks, do look into the proper etiquette of each. Last I heard, commercial presence was a bit frowned upon on Mixi.</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/simple-share-functionality-for-multiple-social-networks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Of tracking and creative development</title>
		<link>http://jansensan.net/of-tracking-and-creative-development</link>
		<comments>http://jansensan.net/of-tracking-and-creative-development#comments</comments>
		<pubDate>Mon, 28 Mar 2011 19:53:59 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Information Architecture]]></category>
		<category><![CDATA[Strategy]]></category>
		<category><![CDATA[Tracking]]></category>
		<category><![CDATA[UX]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=486</guid>
		<description><![CDATA[
As creative developers, we need to be familiar with the concept of tracking. For those of you who are not familiar with the idea, tracking is a way of recording the user's interaction with a website, an installation, a game, or any other interactive piece. For example, you'll notice that I sometimes refer searches people [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Meet my friend spike" src="http://jansensan.net/images/blog/post0021_001.jpg" alt="Meet my friend spike" width="640" height="84" /></p>
<p>As creative developers, we need to be familiar with the concept of tracking. For those of you who are not familiar with the idea, tracking is a way of recording the user's interaction with a website, an installation, a game, or any other interactive piece. For example, you'll notice that I sometimes refer searches people did to end up on my site or what is the most popular post. I can get all that information via tracking.</p>
<p><strong>The purpose</strong></p>
<p>The data obtained from tracking can be used for different purposes. In theory, the strategist should meet with the information architect in the beginning of a project to share the learnings obtained from previous projects. Afterwards, the information architect adapts or corrects wireframes accordingly.</p>
<p>Let's think of a share button on a microsite. If an agency implements a share button, but said button is not used at all in any of it's sites, the strategist could then decide that the share button is either useless, then ask for it's removal. Also, it could mean that it is not either visible enough or in a proper location, that would then be a job for the information architect to rethink where that button should be placed in the site.</p>
<p><strong>Tracking useless data: achievements?</strong></p>
<p>That does mean however that when creating a tracking plan, a strategist might have to be careful to track every of the user's actions, useless data might serve no purpose. But in other contexts, such as games, tracking all sorts of useless things might serve a purpose: achievements.</p>
<p>Many people who are familiar with games know that there are tons of things tracked in there, and since their creation. Asteroid's rocks, Pac-Man pellets and fruits, Donkey Kong's barrels, Super Mario's coins. All those things were tracked in order to present a high score. Pretty basic, and a bit boring by today's standards.</p>
<p><a title="Bubble Bobble on Wikipedia" href="http://en.wikipedia.org/wiki/Bubble_Bobble" target="_blank">Bubble Bobble</a>, an old arcade game, had a lot of undisclosed tracking that affected how power-ups and points were attributed to the player.</p>
<p><img class="aligncenter" title="Bubble Bobble" src="http://www.gamasutra.com/db_area/images/feature/3485/0005.png" alt="Bubble Bobble" width="580" height="508" /></p>
<blockquote><p>Probably the most mysterious is the formula that determines when special items appear. Most players believe it to be random, but actually they're all directly determined by the player's actions. The game maintains counts of a large array of trivia, like bubbles popped, times jumped, water bubbles burst, and times wrapped around the screen. When a counter exceeds a threshold value, a flag is set scheduling the item to be generated in an upcoming level. – Source: <a title=" 	Game Design Essentials: 20 Mysterious Games " href="http://www.gamasutra.com/view/feature/3485/game_design_essentials_20_.php?page=3" target="_blank">Gamasutra - Game Design Essentials: 20 Mysterious Games</a></p></blockquote>
<p>More recently, online gaming has allowed tracking results to be used as bragging rights in between gamers. Services like <a title="XBOX Live" href="http://www.xbox.com/" target="_blank">XBOX Live</a>, <a title="Playstation Network" href="http://www.playstation.com/psn/" target="_blank">Playstation Network</a> and the recent <a title="Apple GameCenter" href="http://www.apple.com/game-center/" target="_blank">Apple GameCenter</a> all allow their players to track seemingly useless data and post it on a more developed online high score board.</p>
<p>A recent game went from indie to fame, <a title="Super Meat Boy" href="http://supermeatboy.com/" target="_blank">Super Meat Boy</a>. That game tracks the attempts of the player to succeed at passing the current level, and at the end of the level, presents a funny replay of all the attempts at the same time.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/GT_a0dcdWac?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/GT_a0dcdWac?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Tracking tools</strong></p>
<p>There are multiple ways to track user interactions. As I have not worked in gaming, I can only mention those about websites, but the idea is mostly the same.</p>
<p>Google offers an easy to use free service, <a title="Google Analytics" href="http://www.google.com/analytics/" target="_blank">Google Analytics</a>. Enterprises oftentimes go with professional companies that offer tracking services, such as <a title="CoreMetrics" href="http://www.coremetrics.com/" target="_blank">CoreMetrics</a>. Even <a title="http://bit.ly/" href="http://bit.ly/" target="_blank">Bitly</a>, the URL shortener service, offers some tracking.</p>
<p>Those who ever worked with banners—ugh, I hate these things—know of something called the <a title="ClickTag on Wikipedia" href="http://en.wikipedia.org/wiki/Clicktag" target="_blank">ClickTag</a>. If you don't know what it really is or never cared to look it up, let me spell it out for you: it's a tracking tag. Yup! Those ad servers hosting the banners track the amount of clicks on those banners. I mean, it's important to the advertiser to know if the banner is successful. And just so you know, a banner click rate (views vs. clicks) is oftentimes less than 1%... Sometimes, they go as far as using <a title="Heat maps on Squidoo" href="http://www.squidoo.com/heat-map" target="_blank">heat maps</a> to know what attracts the user to hover over or click on said banner.</p>
<p>Try tracking tools as much as you can, it is an important skillset to have.</p>
<p><strong>Why should you care?</strong></p>
<p>Well, you may not have to, it all depends on what you want to do. But like in anything, it's good to know how it works and how it affects you and your work.</p>
<p>If you aim to know programming in all its nook and crannies, if you like to optimize the hell out of your code and do not care about the rest of the project lifecycle, tracking will just be an annoying request from your project manager to add some lines of code in your project.</p>
<p>However, if you care about how the project got to what it is, if you care about the user interface and experience, you need to work with a strategist and an information architect before the project is started, and also afterwards once the project is complete to see what are the lessons learned. It is a great way to move forward in the world of development.</p>
<p><strong>Further reading</strong></p>
<p>There are obviously a lot of people writing about SEO, strategy and interaction design. Here are a couple blogs that I find relevant:</p>
<ul>
<li><a href="http://52weeksofux.com/" target="_blank">52 Weeks of UX</a></li>
<li><a href="http://thefuturebuzz.com/" target="_blank">The Future Buzz</a></li>
<li><a href="http://www.getelastic.com/" target="_blank">Get Elastic</a></li>
<li><a href="http://ignorethecode.net/blog/" target="_blank">Ignore the Code</a></li>
<li><a href="http://www.lukew.com/ff/" target="_blank">Luke W: Ideation + Design</a></li>
<li><a href="http://www.uxbooth.com/" target="_blank">UX Booth</a></li>
<li><a href="http://uxmovement.com/" target="_blank">UX Movement</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/of-tracking-and-creative-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Flash with Terminal or Command Prompt</title>
		<link>http://jansensan.net/debugging-flash-with-terminal-or-command-prompt</link>
		<comments>http://jansensan.net/debugging-flash-with-terminal-or-command-prompt#comments</comments>
		<pubDate>Fri, 25 Feb 2011 22:45:47 +0000</pubDate>
		<dc:creator>mat janson blanchet</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://jansensan.net/?p=488</guid>
		<description><![CDATA[All programming languages offer a way to debug and send some info to a console. In the Flash IDE, the traces are displayed in the output window, in Flash Builder/FDT/Eclipse the traces are sent to the console view. And so on.
That is useful while debugging, however most often those traces are needed in the final [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Terminal and Command Prompt" src="http://jansensan.net/images/blog/post0020_001.jpg" alt="" width="640" height="128" />All programming languages offer a way to debug and send some info to a console. In the Flash IDE, the traces are displayed in the output window, in Flash Builder/FDT/Eclipse the traces are sent to the console view. And so on.</p>
<p>That is useful while debugging, however most often those traces are needed in the final context of the Flash piece, like a website.</p>
<p>There are some awesome tools out there that do just that and in style. I'm thinking of <a title="De MonsterDebugger" href="http://demonsterdebugger.com/" target="_blank">De MonsterDebugger</a>. That tool is really good, although it requires some additional classes and long words to write to get something simple (eg: <code>MonsterDebugger.trace(this, "Hello World!")</code>).</p>
<p>There is a context in which that tool cannot be used, and that is Facebook. Ah! the ever hatable social network platform! Facebook does not allow <code>ExternalInterface</code> for security reasons, <span style="text-decoration: line-through;">that is why tools like De MonsterDebugger are not available, this is how data is sent to their debugger</span>. Edit: After receiving a comment, I investigated, it indeed turns out that MonsterDebugger is available when working on Facebook, as it indeed uses <code>LocalConnection</code>. My bad for assuming. However, the use of <code>ExternalInterface</code> is still not possible on Facebook, and the point of this post is more to show how to use the Terminal and Command Prompt to debug.</p>
<p>Sure you could create a textfield and add it to the display list, but that can become tedious if you need to add scrollbars and such.</p>
<p>A good alternative is to use a debugger that functions regardless of context. Adobe's open source <a title="Flex SDK" href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK" target="_blank">Flex SDK</a> comes with the Flash Debugger, a JAR package that can be run with Java from the command line.</p>
<p>Yikes!</p>
<p>That sounds more complicated than it really is actually. Let's see how to run the debugger on Mac OSX and Windows.</p>
<p><strong>Terminal on Mac OSX</strong></p>
<p><img class="aligncenter" title="Flash Debugger in Terminal" src="http://jansensan.net/images/blog/post0020_002.jpg" alt="" width="640" height="390" /></p>
<p>The screenshot above provides already a lot of information on how to run that package, but let's spell it out step by step:</p>
<ol>
<li>Open Terminal</li>
<li>Go to the directory where of the Flex SDK you want to use</li>
<li>Go to the "lib" directory</li>
<li>In that directory, you need to run the "fdb.jar" package. To do so, type "java -jar fdb.jar"</li>
<li>To start the debugger, type "r", for run. The traces and errors will then be displayed in the Terminal</li>
</ol>
<p>This will work for all SWFs published with debugging enabled, whether they are local or online, and that is where it becomes useful, for debugging stuff online. Just make sure then that you installed the debugger version of the Flash Player so it can communicate with the Terminal.</p>
<p><strong>Command Prompt on Windows</strong></p>
<p><img class="aligncenter" title="Flash Debugger in Command Prompt" src="http://jansensan.net/images/blog/post0020_003.jpg" alt="" width="640" height="390" /></p>
<p>It's pretty much the same on Windows with the Command Prompt. You can see here that I use Windows XP, so I'm sorry if there are slight differences on Vista or 7, I don't have those OSes.</p>
<ol>
<li>Open the Command Prompt</li>
<li>Go to the directory where of the Flex SDK you want to use</li>
<li>Go to the "lib" directory</li>
<li>In that directory, you need to run the "fdb.jar" package. To do so, type "java -jar fdb.jar"</li>
<li>To start the debugger, type "r", for run. The traces and errors will then be displayed in the Command Prompt</li>
</ol>
<p>Happy debugging!</p>
]]></content:encoded>
			<wfw:commentRss>http://jansensan.net/debugging-flash-with-terminal-or-command-prompt/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

