<?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>labs.hapticdata.com &#187; open-source</title>
	<atom:link href="http://labs.hapticdata.com/category/development/open-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.hapticdata.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Mar 2012 07:20:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Toxiclibsjs v0.1.0</title>
		<link>http://labs.hapticdata.com/2012/01/toxiclibsjs-v0-1-0/</link>
		<comments>http://labs.hapticdata.com/2012/01/toxiclibsjs-v0-1-0/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 19:09:28 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[toxiclibs.js]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://labs.hapticdata.com/?p=721</guid>
		<description><![CDATA[One year ago, I began porting a couple classes from Toxiclibs over to JavaScript. Now with 90 classes ported and several more nearly completed, Toxiclibsjs is beginning to take shape. As of today, Toxiclibsjs is being built to the AMD API. It can be used with RequireJS, Node.js or the common way of a single [...]]]></description>
			<content:encoded><![CDATA[<p>One year ago, I began porting a couple classes from <a href="http://toxiclibs.org">Toxiclibs</a> over to JavaScript. Now with 90 classes ported and several more nearly completed, <a href="http://haptic-data.com/toxiclibsjs">Toxiclibsjs</a> is beginning to take shape.  </p>
<p>As of today, Toxiclibsjs is being built to the <a href="https://github.com/amdjs/amdjs-api/wiki/AMD">AMD</a> API. It can be used with <a href="http://requirejs.org">RequireJS</a>, <a href="http://nodejs.org">Node.js</a> or the common way of a single global object as before. Being available in this manner means that not only is Toxiclibsjs available for the same uses as before, but now it can be used on the server-side and with desktop-based javascript programming environments such as <a href="http://plask.org">Plask</a>.</p>
<p><span id="more-721"></span></p>
<p>If you would like to use toxiclibsjs within Node.js it is now available on <a href="http://search.npmjs.org/#/toxiclibsjs">NPM</a> and can be installed easily:</p>
<p><code>$ npm install toxiclibsjs</code></p>
<p>Along with this progress there are now several new classes:</p>
<ul>
<li>toxi.math.noise.PerlinNoise</li>
<li>toxi.math.noise.simplexNoise</li>
<li>toxi.math.conversion.unitTranslator</li>
<li>toxi.processing.ToxiclibsSupport</li>
<li>toxi.THREE.ToxiclibsSupport</li>
</ul>
<p>Toxiclibsjs now follows the same package structure as the original Toxiclibs. So, if you previously used <em>toxi.Vec2D</em>, now you would use <em>toxi.geom.Vec2D</em> and this is consistent with all documentation for the original library. This can have a positive impact on users of both <a href="http://processing.org">Processing</a> and <a href="http://processingjs.org">Processing.js</a> because now you can refer to your toxiclibs class in long-form and in many more scenarios it will work without altering your code. Along these same objectives, one of the new classes that has been added is <em>toxi.processing.ToxiclibsSupport</em> this class, available in both versions will also ease moving between environments.</p>
<p>Since the release of Toxiclibsjs, I have tracked down several examples of its use on the internet, such as <a href="http://twitter.com/rhyme_andreason">Mary Huang</a>&#8216;s <a href="http://www.shapeways.com/creator/sake-set/">Sake set Creator for Shapeways</a> and <a href="http://twitter.com/gregkepler">Greg Kepler</a>&#8216;s <a href="http://gregkepler.com/work/js/spiderwebs/">Spider Web generator</a>. I have also used it several of my own projects, such as our studio site for <a href="http://kvsstudio.com">KVS Studio</a> and sketches such as this <a href="http://haptic-data.com/sketches/simplex_trails.html">Simplex Trails sketch</a> I did recently. </p>
<p>Progress is being made to follow the path that <a href="http://twitter.com/toxi">Karsten Schmidt</a> has set in his post <a href="http://toxiclibs.org/2011/09/the-road-ahead/">The Road Ahead</a>. There is now more documentation <a href="http://github.com/hapticdata/toxiclibsjs">in the github repository</a>. I will continue to be improving documentation and will be providing unit tests in the future.</p>
<p>Here are some links to the pieces mentioned as well as the new <a href="http://haptic-data.com/toxiclibsjs">examples on the site</a>:<br />
<a href="http://www.shapeways.com/creator/sake-set/"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/Sake-Set-Creator.jpg" alt="" title="Sake-Set-Creator" width="213" height="165" class="alignnone size-full wp-image-724" /></a><a href="http://gregkepler.com/work/js/spiderwebs/"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/Kepler-Web.jpg" alt="" title="Kepler-Web" width="213" height="165" class="alignnone size-full wp-image-725" /></a><a href="http://kvsstudio.com"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/kvs.jpg" alt="" title="kvs" width="213" height="165" class="alignnone size-full wp-image-726" /></a><a href="http://haptic-data.com/sketches/simplex_trails.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/simplex_trails_th.jpg" alt="" title="simplex_trails_th" width="213" height="165" class="alignnone size-full wp-image-727" /></a><a href="http://haptic-data.com/toxiclibsjs/examples/PerlinNoise_canvas.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/perlin_noise_field.jpg" alt="" title="perlin_noise_field" width="213" height="165" class="alignnone size-full wp-image-728" /></a><a href="http://www.haptic-data.com/toxiclibsjs/examples/SimplexNoise_canvas.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2012/01/simplex_noise.jpg" alt="" title="simplex_noise" width="213" height="165" class="alignnone size-full wp-image-729" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2012/01/toxiclibsjs-v0-1-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Proposal for a more-private Facebook &#8220;Like&#8221;</title>
		<link>http://labs.hapticdata.com/2011/12/proposal-for-a-more-private-facebook-like/</link>
		<comments>http://labs.hapticdata.com/2011/12/proposal-for-a-more-private-facebook-like/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 20:14:05 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[open-source]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://labs.hapticdata.com/?p=678</guid>
		<description><![CDATA[The Facebook &#8220;Like&#8221; button is a bit cruel. It tracks every site you go to and stores that information on their servers. They use that information to target you and your friends with advertising. To many, this is an un-ethical practice, but site owners have a reliance on it for generating traffic. The same sites [...]]]></description>
			<content:encoded><![CDATA[<p><img class="labs-lead-in" src="http://labs.hapticdata.com/wp-content/uploads/2011/12/fb_labs.gif" alt="" title="fb_labs" width="640" height="360" class="alignnone size-full wp-image-708" /></figure>
<p>The <a href="http://www.google.com/search?hl=en&#038;gl=us&#038;tbm=nws&#038;btnmeta_news_search=1&#038;q=facebook+like+button+privacy&#038;oq=facebook+like+button+privacy&#038;aq=f&#038;aqi=d1d-o1&#038;aql=&#038;gs_sm=e&#038;gs_upl=2014l5824l0l6087l32l30l2l22l24l0l154l745l2.4l6l0">Facebook &#8220;Like&#8221; button is a bit cruel</a>. It tracks every site you go to and stores that information on their servers. They use that information to target you and your friends with advertising. To many, this is an un-ethical practice, but site owners have a reliance on it for generating traffic. The same sites you see writing about Facebook privacy concerns have the button attached to their article. </p>
<p><strong>My proposal is that developers defer the loading of the &#8220;Like&#8221; button script by requiring a click event from the user first</strong>. I have created a project that is a quick-stab at allowing a site owner to leverage a <a href="http://developers.facebook.com/docs/reference/plugins/like/">Facebook Like button</a>, while making the invasion more voluntary for the user, in this manner.</p>
<p>Facebook is receiving a lot of heat over the information they are storing, but as web developers we also do have some responsibility in the matter. Just because its the code Facebook gives you, doesn&#8217;t mean its the exact code that you have to use. While I admit, my quick-stab is a bit hack, and it only covers one style of implementation (the &#8220;button_counts&#8221; style), my hope is that site-creators will consider creating a solution that fits their needs and is kinder to the privacy of their audience.</p>
<p><span id="more-678"></span></p>
<h2>What my implementation does…</h2>
<p>Not much. All the script does is use a temporary image in the place of the Like button, clicking that image is a trigger to load the invasive facebook like button and swap them.  If this was widely applied to sites it would change the information that Facebook has from being every site that a user visits, to being every site that user interacts with the Like button functionality on.</p>
<p><strong>Like this article with the button below, to try it out!</strong></p>
<div id="fb-root"></div>
<div class="fb-like" data-href="http://labs.hapticdata.com/2011/12/proposal-for-a-more-private-facebook-like/" data-layout="button_count" data-send="false" data-width="450" data-show-faces="true"></div>
<p><script type="text/javascript" src="http://labs.hapticdata.com/wp-content/uploads/2011/12/private-like1.js"></script><br />
<script type="text/javascript">
    addPrivateLike();
    </script></p>
<p>I have set up a <a href="https://github.com/hapticdata/facebook-like-increased-privacy">code repository for this extremely-slim example on github</a>. Feel free to use it in any way you wish.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2011/12/proposal-for-a-more-private-facebook-like/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toxiclibs.js gets VerletPhysics2D</title>
		<link>http://labs.hapticdata.com/2011/05/toxiclibs-js-gets-verletphysics2d/</link>
		<comments>http://labs.hapticdata.com/2011/05/toxiclibs-js-gets-verletphysics2d/#comments</comments>
		<pubDate>Tue, 24 May 2011 15:21:40 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[open-source]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[toxiclibs.js]]></category>

		<guid isPermaLink="false">http://labs.hapticdata.com/?p=649</guid>
		<description><![CDATA[It&#8217;s been four months since I initially started creating Toxiclibs.js a JavaScript version of toxiclibs. So far, over 65 &#8216;classes&#8217; have been written. These classes cover a wide spectrum of functionality that I believe can be helpful on any web project. There are currently 18 examples on the site, most of which have focused on [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been four months since I initially <a href="http://labs.hapticdata.com/2011/01/toxiclibs-js-open-source-computational-design/">started creating Toxiclibs.js</a> a JavaScript version of <a href="http://toxiclibs.org">toxiclibs</a>. So far, over 65 &#8216;classes&#8217; have been written. These classes cover a wide spectrum of functionality that I believe can be helpful on any web project. </p>
<p>There are currently 18 examples on <a href="http://haptic-data.com/toxiclibsjs">the site</a>, most of which have focused on being direct ports of the examples from Toxiclibs. Of these examples 14 use <a href="http://processingjs.org">Processing.js</a>, 1 uses <a href="http://github.com/mrdoob/three.js">Three.js</a>, 1 uses <a href="http://raphaeljs.com">Raphael.js</a>, 1 uses Canvas&#8217; 2D API and the other Canvas&#8217; WebGL API. There also is <a href="https://github.com/jonobr1/toxiclibsjs/commit/b97b0e6e58d5e1960d646ef6e1f81171af0ffd8d">an example using Gee</a> committed by <a href="https://github.com/jonobr1">jonobr1</a>. In the future I will be expanding on examples that help clarify the libraries JavaScript nature and independence. </p>
<p>The last 4 examples on the site demonstrate the newest package for Toxiclibs.js, VerletPhysics2D. This package is a light-weight physics engine that is simple to work with and runs well, the <a href="http://haptic-data.com/toxiclibsjs/examples/Attraction2D_pjs.html">Attraction 2D example</a> performs smoothly with 250 particles. VerletPhysics2D includes a base particle class, behaviors, constraints and springs. Behaviors (such as Gravity or Attraction/Repulsion), constraints, and springs are easily applied to the physics world as a whole or to individual particles. You can compare its use with <a href="http://toxiclibs.org/docs/verletphysics/">the java documentation for physics2d</a>. I am very excited to have completed this portion of the library, I feel that it fits a void that isn&#8217;t currently filled by other physics engines in JavaScript, so <a href="https://github.com/hapticdata/toxiclibsjs/archives/master">please download it</a> and give it a try! And check <a href="http://haptic-data.com/toxiclibsjs/">the site for the new examples</a>.</p>
<p><span id="more-649"></span></p>
<p><a href="http://haptic-data.com/toxiclibsjs/examples/Attraction2D_pjs.html"><img src="http://haptic-data.com/toxiclibsjs/img/physics2d_attraction2d.gif"></a><a href="http://haptic-data.com/toxiclibsjs/examples/SoftBodySquare_pjs.html"><img src="http://haptic-data.com/toxiclibsjs/img/physics2d_softbodysquare.gif"></a><a href="http://haptic-data.com/toxiclibsjs/examples/ThreadDemo_pjs.html"><img src="http://haptic-data.com/toxiclibsjs/img/physics2d_threaddemo.gif"></a><a href="http://haptic-data.com/toxiclibsjs/examples/DraggableParticles_pjs.html"><img src="http://haptic-data.com/toxiclibsjs/img/physics2d_draggableparticles.gif"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2011/05/toxiclibs-js-gets-verletphysics2d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toxiclibs.js &#8211; open-source computational design</title>
		<link>http://labs.hapticdata.com/2011/01/toxiclibs-js-open-source-computational-design/</link>
		<comments>http://labs.hapticdata.com/2011/01/toxiclibs-js-open-source-computational-design/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 07:17:21 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[pjs]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[toxiclibs.js]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://labs.hapticdata.com/?p=613</guid>
		<description><![CDATA[I have initiated a new open-source project titled Toxiclibs.js. Toxiclibs.js is a JavaScript port of Karsten Schmidt&#8216;s expansive toxiclibs library. Contributed libraries are an excellent perk of using Processing, and to me there is no library that stands as strong as Karsten&#8217;s. Toxiclibs encapsulates a lot of the complexity involved with common computational design problems [...]]]></description>
			<content:encoded><![CDATA[<p>I have initiated a new open-source project titled <a href="http://haptic-data.com/toxiclibsjs">Toxiclibs.js</a>. Toxiclibs.js is a JavaScript port of <a href="http://postspectacular.com">Karsten Schmidt</a>&#8216;s expansive <a href="http://toxiclibs.org">toxiclibs</a> library.<br />
Contributed libraries are an excellent perk of using <a href="http://processing.org">Processing</a>, and to me there is no library that stands as strong as Karsten&#8217;s. Toxiclibs encapsulates a lot of the complexity involved with common computational design problems and has a very large scope of what it can accomplish.</p>
<p>A great deal of my work involves using HTML5&#8242;s canvas tag for generative design; much of the time with the help of <a href="http://processingjs.org">Processing.js</a>. Repeatedly, I have spent the time of stripping out references to toxiclibs to make my code work with PJS. I worked-around porting the library for some time because it felt like too large of a project to do by myself. Last week as I was working on a <a href="http://en.wikipedia.org/wiki/WebGL">WebGL</a>  visualization, I decided it was worth it to port the Vec3D class, and couldn&#8217;t stop there. I decided that this has to be done, I badly want these libraries and there have got to be many others thinking the same thing. I encourage anyone interested to contribute to the project.</p>
<p>I am hosting my source at gitHub, <a href="http://github.com/hapticdata/toxiclibsjs">http://github.com/hapticdata/toxiclibsjs</a>, and I have prepared an intial round of examples that you can view at <a href="http://haptic-data.com/toxiclibsjs">http://haptic-data.com/toxiclibsjs</a>. </p>
<p><span id="more-613"></span></p>
<p>The code already includes several classes for both 2D and 3D use, there are currently examples on several topics, such as <a href="http://haptic-data.com/toxiclibsjs/examples/TColor_pjs.html">using the TColor class for blending, converting and modifying colors</a>, using Line2D, Vec2D and many others. If you aren&#8217;t a PJS user, one of the great things about this library is that it has no dependency on Processing.js. This is all JavaScript, with no dependencies, it can be used with other libraries, such as <a href="http://raphaeljs.org">Raphael.js</a>, or it can be used by itself.</p>
<p><a href="http://haptic-data.com/toxiclibsjs/examples/Line2DIntersection_pjs.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2011/01/Line2DIntersection.gif" alt="" title="Line2DIntersection" width="320" height="320" class="alignnone size-full wp-image-616" /></a><a href="http://haptic-data.com/toxiclibsjs/examples/PolarUnravel_pjs.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2011/01/polarunravel.gif" alt="" title="polarunravel" width="320" height="320" class="alignnone size-full wp-image-617" /></a><a href="http://haptic-data.com/toxiclibsjs/examples/WheelInsets_pjs.html"><a href="http://haptic-data.com/toxiclibsjs/examples/AdditiveWaves_pjs-webgl.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2011/01/additivewaves.jpg" alt="" title="additivewaves" width="320" height="320" class="alignnone size-full wp-image-635" /></a><a href="http://haptic-data.com/toxiclibsjs/examples/ArcPolarCoordinates_pjs.html"><img src="http://labs.hapticdata.com/wp-content/uploads/2011/01/arccoord.gif" alt="" title="Arc Polar Coordinates Examples" width="320" height="320" class="alignnone size-full wp-image-615" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2011/01/toxiclibs-js-open-source-computational-design/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Post-Flashbelt Experimentation</title>
		<link>http://labs.hapticdata.com/2009/07/post-flashbelt-experimentation/</link>
		<comments>http://labs.hapticdata.com/2009/07/post-flashbelt-experimentation/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:17:19 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://labs.hapticdata.com/?p=263</guid>
		<description><![CDATA[Rather than repeating tidbits I picked up here and there, I want to show some things I have thrown together since Flashbelt and provide the source.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashbelt.com">Flashbelt</a> has come and gone for 2009, and again it was an experience that I feel lucky to have been a part of. It was great to spend 3 days with like-minded designers and developers; and to listen to presenters show where the past year has led them. Presenters demonstrated completed projects, experiments and the new tools they are using. Rather than repeating tidbits I picked up here and there, I want to show some things I have thrown together since Flashbelt. These are just some quick demos, for me they mainly serve as a form of notes to get familiar with some of the new features and also were thrown together as a quick &#8216;capabilities demo&#8217; for the team.
</p>
<p>
Below are three demos and source code. These demos use some new features, I wrote these for use with the free <a href="http://labs.adobe.com/technologies/flex4sdk/">Flex 4 SDK</a>, which you can also use with <a href="http://labs.adobe.com/technologies/flashbuilder4/">Flash Builder 4 Beta</a>, these classes are all very simple to convert for use with Flash CS4 instead.</p>
<p><span id="more-263"></span></p>
<p><strong>Slide 1:</strong> <em>Click on the photo and it shatters into pieces.</em> This is a custom effect I built after some inspiration from <a href="http://www.newmovieclip.com">Koen De Weggheleire&#8217; s</a> presentation &#8220;Play with Vectors.&#8221; For this effect I am drawing a 5&#215;5 grid of rectangles and filling them with their respective pixel&#8217;s from the original source image. When the image is clicked the pieces have physics properties applied to propel them.</p>
<pre class="code">
<code>
package com.hapticdata.fb2009
{
	import com.hapticdata.phsyics.AngularVelocityVector;
	import com.theflashblog.fp10.SimpleZSorter;
	import flash.geom.Vector3D;
	import flash.geom.Matrix3D;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.geom.Point;
	import flash.geom.Matrix;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.display.Stage;
	import flash.display.Sprite;

	/**
	 * Exploading picture,
	 * image is embedded split into a grid, the respective pixels are copied to the Sprite,
	 * and AngularVelocityVector is used for the animation
	 * @author kphillips
	 */
	public class ExplodingPicture extends Sprite
	{

		[Embed (source="../../../../eyes4.jpg")]
		private var imgClass:Class;

		public var bd:BitmapData;

		public var columns:int = 10;
		public var rows:int = 10;

		public var gridWidth:int;
		public var gridHeight:int;

		public var container:Sprite;

		public var items:Vector.<Sprite>;
		public var avVectors:Vector.<AngularVelocityVector>;

		public var hasExploded:Boolean = false;
		public var axis:Vector.<Vector3D>;

		public var _stage:Stage;
		override public function get stage():Stage
		{
			return _stage;
		}

		public function ExplodingPicture(stage:Stage=null)
		{
			if(!stage)
			{
				stage = this.stage;
				_stage = this.stage;
			}
			else
			{
				this._stage = stage;
			}

			axis = new Vector.<Vector3D>();
			axis[0] = Vector3D.X_AXIS;
			axis[1] = Vector3D.Y_AXIS;
			axis[2] = Vector3D.Z_AXIS;

			avVectors = new Vector.<AngularVelocityVector>();

			addEventListener(Event.ENTER_FRAME,handleEnterFrame);

			container = new Sprite();
			container.x = stage.stageWidth*0.5;
			container.y = stage.stageHeight*0.5;
			addChild(container);

			bd = (new imgClass() as Bitmap).bitmapData;

			gridWidth = bd.width / columns;
			gridHeight = bd.height / rows;

			items = new Vector.<Sprite>();
			for(var c:int=0;c < columns;c++)
			{
				for(var r:int=0;r < rows;r++)
				{
					var s:Sprite = new Sprite();
					var m:Matrix = new Matrix();

					var rectBD:BitmapData = new BitmapData(gridWidth,gridHeight);
					rectBD.copyPixels(bd, new Rectangle(c*gridWidth,r*gridHeight,gridWidth,gridHeight), new Point(0,0));
					s.graphics.beginBitmapFill(rectBD,m);
					s.graphics.drawRect(0,0,gridWidth,gridHeight);
					s.graphics.endFill();
					s.addEventListener(MouseEvent.CLICK,handleMouseClick)

					items.push(s);
					container.addChild(s);
					var sx:Number = (c*gridWidth) - (bd.width*0.5);
					var sy:Number = (r*gridHeight) - (bd.height*0.5);
					s.transform.matrix3D = new Matrix3D();
					s.transform.matrix3D.appendTranslation(sx, sy, 0);

					var av:AngularVelocityVector = new AngularVelocityVector();
					av.vector = {x: s.x, y: s.y};
					av.forces = {vx: 0, vy:Math.random()*-25,angle:Math.random()*360, wind: -1, gravity: 4, drag: 0.999};
					avVectors.push(av);
				}
			}
		}

		private function handleEnterFrame(event:Event):void
		{
			if(hasExploded)
			{
				for(var i:uint=0;i < items.length;i++)
				{
					avVectors[i].step();
					items[i].x = avVectors[i].x;
					items[i].y = avVectors[i].y;

					var rot:int = 4;
					if(i&#038;1)rot *= -1;

					items[i].transform.matrix3D.appendRotation(rot, axis[i%axis.length]);
				}
			}
			SimpleZSorter.sortClips(container);
		}

		private function handleMouseClick(event:MouseEvent):void
		{
			hasExploded = true;
			(event.target as Sprite).transform.matrix3D.appendRotation(45,Vector3D.Z_AXIS);
		}
	}
}
</code>
</pre>
<p>The next 2 examples also were inspired by Koen's presentation. With Flash CS4 there is now a native 3d environment, using the <a href="http://livedocs.adobe.com/flex/3/langref/flash/geom/Matrix3D.html">Matrix3D</a> class it simple to work in three dimensions without the use of a third-party library like <a href="http://blog.papervision3d.org/">Papervision3D</a> or <a href="http://away3d.com/">Away3D</a>. I did however need to use <a href="http://theflashblog.com/?p=470">SimpleZSorter</a>, a great class I found on Lee Brimelow's <a href="http://theflashblog.com/">The Flash Blog</a>.</p>
<p><strong>Slide 2:</strong><em> Accelerated Drawing using Vectors and 3D Transformations.</em> This slide will draw 1000 squares in a 3d space, something that previously would've been very difficult for flash. Now using <a href="http://livedocs.adobe.com/flex/3/langref/Vector.html">Vector</a> (so much better than un-typed arrays), and some new drawing classes such as <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/GraphicsPathCommand.html">GraphicsPathCommand</a> the drawing is very manageable on your systems resources.</p>
<pre class="code">
<code>
package com.hapticdata.fb2009
{
	import flash.display.BitmapData;
	import flash.display.GraphicsBitmapFill;
	import flash.display.GraphicsPath;
	import flash.display.GraphicsPathCommand;
	import flash.display.GraphicsPathWinding;
	import flash.display.GraphicsSolidFill;
	import flash.display.GraphicsStroke;
	import flash.display.IGraphicsData;
	import flash.display.LineScaleMode;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.geom.Matrix3D;
	import flash.geom.Point;
	import flash.geom.Vector3D;

	/**
	 * Drawing3D, using the Vector class and GraphicsPathCommands to accelerate drawing
	 * @author kphillips
	 */
	public class Drawing3D extends Sprite
	{

		public var i:int = 0;
		public var numShapes:int = 1000;

		public var commands:Vector.<int>;
		public var coords:Vector.<Number>;

		public var container:Sprite;
		public var shape:Sprite;

		public var _stage:Stage;

		override public function get stage():Stage {
			return _stage;
		}

		public function Drawing3D(stage:Stage = null)
		{
			if(!stage)
			{
				stage = this.stage;
				_stage = this.stage;
			}
			else
			{
				this._stage = stage;
			}
			container = new Sprite();
			container.x = stage.stageWidth * 0.5;
			container.y = stage.stageHeight * 0.5;

			addChild(container);

			commands = new Vector.<int>();
			commands[0] = GraphicsPathCommand.MOVE_TO;
			commands[1] = GraphicsPathCommand.LINE_TO;
			commands[2] = GraphicsPathCommand.LINE_TO;
			commands[3] = GraphicsPathCommand.LINE_TO;
			commands[4] = GraphicsPathCommand.LINE_TO;
			//
			commands[5] = GraphicsPathCommand.MOVE_TO;
			commands[6] = GraphicsPathCommand.LINE_TO;
			commands[7] = GraphicsPathCommand.LINE_TO;
			commands[8] = GraphicsPathCommand.LINE_TO;
			commands[9] = GraphicsPathCommand.LINE_TO;

			addEventListener(Event.ENTER_FRAME, handleEnterFrame);
		}

		private function handleEnterFrame(event:Event):void
		{
			if(i++ < numShapes)
			{
				//create shape
				var shape:Sprite = new Sprite();
				shape.transform.matrix3D = new Matrix3D();
				shape.transform.matrix3D.appendTranslation(-stage.stageWidth * 0.5, -stage.stageHeight * 0.5, Math.random() * 50 - 25);
				container.addChild(shape);

				var pt:Point = new Point(Math.random() * stage.stageWidth, Math.random() * stage.stageHeight);
				var width:int = Math.random() * 25 + 1
				var height:int = Math.random() * 25 + 1;
				coords = new Vector.<Number>();

				//left x
				coords[0] = pt.x - (width * 0.5);
				//top y
				coords[1] = pt.y - (height * 0.5);
				//right x
				coords[2] = pt.x + (width * 0.5);
				coords[3] = coords[1];

				coords[4] = coords[2];
				//bottom-y
				coords[5] = pt.y + (height * 0.5);

				coords[6] = coords[0];
				coords[7] = coords[5];

				coords[8] = coords[0];
				coords[9] = coords[1];

				var drawingData:GraphicsPath = new GraphicsPath(commands, coords, GraphicsPathWinding.NON_ZERO);
				var fillBitmap:GraphicsBitmapFill = new GraphicsBitmapFill(new BitmapData(width, height, true, Math.random() * 0xFFFFFF00));
				var stroke:GraphicsStroke = new GraphicsStroke(1, true, LineScaleMode.NONE, "none", "round", 3, new GraphicsSolidFill(0xffffff, 1));

				var graphicsData:Vector.<IGraphicsData> = new Vector.<IGraphicsData>();
				//fill
				graphicsData[0] = fillBitmap;
				//stroke
				graphicsData[1] = stroke;
				//data
				graphicsData[1] = drawingData;	//i don't want a stroke

				shape.transform.matrix3D.appendRotation(Math.random() * 360, Vector3D.Y_AXIS);
				shape.transform.matrix3D.appendRotation(Math.random() * 360, Vector3D.X_AXIS);

				shape.graphics.drawGraphicsData(graphicsData);

			}

			container.rotationY++;
		}
	}
}
</code>
</pre>
<p><strong>Slide 3:</strong> <em>Controlling an object's rotation in 3D</em> There isn't much new here, I'm just trying to show simple control of the environment. You can see how we can implement 3D planes and rotation very simply, this could open up some doors for possible navigations in future projects without a large time investment.</p>
<pre class="code">
<code>
package com.hapticdata.fb2009
{
	import flash.text.TextFormat;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextField;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;

	import com.theflashblog.fp10.SimpleZSorter;
	import flash.geom.Matrix3D;
	import flash.geom.Point;
	import flash.events.Event;
	import flash.display.Bitmap;
	import flash.display.Sprite;

	/**
	 * Rotating3D, an embedded object, rotating in a 3d environment
	 * @author kphillips
	 */
	public class Rotating3D extends Sprite
	{
		[Embed (source="../../../../tree.png")]
		private var imgClass:Class;

		public var original:Bitmap;

		//circle properties
		public var radius:int = 150;
		public var center:Point;

		public var numItems:int = 8;

		public var rotY:Number=0;
		public var rotZ:Number=0;

		public var container:Sprite;
		public var items:Vector.<Bitmap>;

		public var _stage:Stage;
		override public function get stage():Stage
		{
			return _stage;
		}

		public function Rotating3D(stage:Stage=null)
		{
			if(!stage)
			{
				stage = this.stage;
				_stage = this.stage;
			}
			else
			{
				this._stage = stage;
			}
			stage.addEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);
			center = new Point(stage.stageWidth*0.5,stage.stageHeight*0.5);

			var tF:TextField = new TextField();
			tF.defaultTextFormat = new TextFormat("arial");
			tF.autoSize = TextFieldAutoSize.LEFT;
			tF.text = "move mouse to rotate";
			tF.x = 10;
			tF.y = 10;
			addChild(tF);

			container = new Sprite();
			container.x = center.x;
			container.y = center.y;
			addChild(container);
			container.addEventListener(MouseEvent.CLICK,handleClick);

			original = new imgClass() as Bitmap;

			items = new Vector.<Bitmap>();
			var radialStep:Number = 360 / numItems;
			for(var i:uint=0;i < numItems;i++)
			{
				items[i] = new Bitmap(original.bitmapData.clone());
				items[i].transform.matrix3D = new Matrix3D();
				var rotZ:int =radialStep * i;

				items[i].transform.matrix3D.appendTranslation(-items[i].width*0.5, -items[i].height*0.5, 0);
				items[i].transform.matrix3D.appendRotation(rotZ,Vector3D.Y_AXIS);

				container.addChild(items[i]);

			}

			//SimpleZSorter.sortClips(container);

			//container.rotationX += 60;
			//container.rotationX += 15;
			addEventListener(Event.ENTER_FRAME,handleEnterFrame);
		}

		private function handleMouseMove(event:MouseEvent):void
		{
			var distX:Number = mouseX - center.x;
			var distY:Number = mouseY - center.y;

			rotY = distX / (stage.stageWidth*0.5);
			rotZ = distY / (stage.stageHeight*0.5);
		}

		private function handleClick(event:MouseEvent):void
		{
                        //move back in z-space every click
			//if(event.target is Bitmap)
			//{
				event.target.transform.matrix3D.appendTranslation(0,0,10);
			//}
		}

		private function handleEnterFrame(event:Event):void
		{
			container.rotationY+=(rotY*-2);
			container.rotationZ+=(rotZ*-2);
			SimpleZSorter.sortClips(container);
		}
	}
}
</code>
</pre>
<p>
<object width="500" height="425">
<param name="movie" value="http://labs.hapticdata.com/wp-content/uploads/2009/07/presentation.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="500" height="425" src="http://labs.hapticdata.com/wp-content/uploads/2009/07/presentation.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
<br />
<a href="http://labs.hapticdata.com/wp-content/uploads/2009/06/hd-fbexamples.zip">hd-fbexamples.zip</a> (source files)</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2009/07/post-flashbelt-experimentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AdvArray for Actionscript 3</title>
		<link>http://labs.hapticdata.com/2008/10/advarray-for-actionscript-3/</link>
		<comments>http://labs.hapticdata.com/2008/10/advarray-for-actionscript-3/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 17:34:57 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[open-source]]></category>
		<category><![CDATA[as3]]></category>

		<guid isPermaLink="false">http://labs.haptic-data.com/?p=15</guid>
		<description><![CDATA[I wrote a brief class extending Actionscript 3&#8242;s Array class. Each time that I have found myself repeating common array tasks I have tried to add it. The AdvArray Documentation contains a list of the methods I have added. The ones I find the most helpful are probably clone() and rotate(). package com.hapticdata { import [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a brief class extending Actionscript 3&#8242;s Array class. Each time that I have found myself repeating common array tasks I have tried to add it. The <a href="http://labs.haptic-data.com/wp-content/uploads/2008/10/AdvArray.html">AdvArray Documentation</a> contains a list of the methods I have added. The ones I find the most helpful are probably <a href="http://labs.haptic-data.com/wp-content/uploads/2008/10/AdvArray.html#clone()">clone()</a> and <a href="http://labs.haptic-data.com/wp-content/uploads/2008/10/AdvArray.html#rotate()">rotate()</a>.</p>
<pre class="code">
<code>
package com.hapticdata {

	import flash.utils.ByteArray;

	/**
	 * Adds extra methods to arrays for easier manipulation
	 * @class AdvArray
	 * @author Kyle Phillips - <a href="http://www.haptic-data.com">http://www.haptic-data.com</a>
	 * @created Jun 29, 2008
	 */
	dynamic public class AdvArray extends Array {
		public function AdvArray(...args) {
			//this = this as Array;
			for each(var i:* in args)
			{
				super.push(i);
			}
			//super(...args);
		}

		 /**
		  * add an array to the end of the existing AdvArray
		  * @param a (Array) the array to append
		  * @return the new length of the array
		  */
		 public function append(a:Array):uint
		 {
		 	for(var i:uint=0;i < a.length;i++)
		 	{
		 		super.push(a[i]);
		 	}
		 	return super.length;
		 }
		 /**
		  * add an array at a given index of the existing AdvArray, defaults to the beginning of the array
		  * @param a (Array) the array to append
		  * @param index (uint) the index of the array to start placing the new array
		  * @return the new length of the array
		  */
		 public function appendAt(a:Array,index:uint=0):uint
		 {
		 	append(a);
		 	rotate(((a.length)+index)*-1);
		 	return super.length;
		 }
		/**
		 * allows you to search the array for a specific value, similar to MovieClip.contains()
		 * @param i (*) the value you are searching the array for
		 * @return returns Boolean
		 * @example
		 * if(myArray.contains("my string"))var myString:String = myArray.pluck(myArray.indexOf("my string"));
		 */
		public function contains(i:*):Boolean
		{
			var index:int = this.indexOf(i);
			return (index != -1) ? true : false;
		}

		/**
		 * pull an item out of the array by its index and re-sort the array
		 * @param index (int) the index of the array to pluck
		 * @return the item that was removed from the array
		 */
		public function pluck(index:int):* {
			return super.splice(index,1);
		}

		/**
		 * allows you to cycle an array one step forward, placing the first item at the end of the array
		 * @return returns the new AdvArray
		 */
		public function rotateForward():Array {
			var firstItem:* = super.shift();
			super.push(firstItem);
			return this;
		}
		/**
		 * allows you to cycle an array one step backwards, placing the last item at the beginning of the array
		 * @return returns the new AdvArray
		 */
		public function rotateBackwards():Array {
			var lastItem:* = super.pop();
			super.unshift(lastItem);
			return this;
		}
		/**
		 * allows you to specify a positive or negative value to cycle the array, 0 will do nothing
		 * @param inc (int) positive or negative value for direction and amount to rotate the array
		 * @return returns the new AdvArray
		 */
		public function rotate(inc:int=1):Array {
			if(inc > 0)
			{
				for(var j:int=0;j < inc;j++) rotateForward();
			}
			else if(inc<0)
			{
				for(var k:int=0;k > inc;k--)rotateBackwards();
			}
			return this;
		}
		/**
		 * makes a shallow copy of the current array
		 * Flex3 LiveDocs: In a shallow copy, if the original array has elements that are objects, only the
		 * references to the objects are copied rather than the objects themselves. The copy points to the same objects as the original does.
		 * Any changes made to the objects are reflected in both arrays.<http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_6.html>
		 * @return a shallow copy of the current array
		 */
		public function shallowCopy():Array
		{
			return super.concat();
		}

		/**
		 * makes a deep copy of the current array
		 * Flex3 LiveDocs: In a deep copy, any objects found in the original array are also copied
		 * so the the new array does not point to the same objects as does the original array. <http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_6.html>
		 * @return a deep copy of the current array
		 */
		public function clone():Array
		{
    		var myBA:ByteArray = new ByteArray();
    		myBA.writeObject(super);
    		myBA.position = 0;
    		return(myBA.readObject());
		}

	}
}
</code>
</pre>
<p>Download the source:<br />
<a href="http://labs.haptic-data.com/wp-content/uploads/2008/10/advarray.as">AdvArray.as</a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.hapticdata.com/2008/10/advarray-for-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

