AS3 Motion Tracking and Detection

Update

Ok, you can now grab the MotionTracker source code (AS2 & AS3). Version 2 eventually will include the other methods for detecting and tracking motion which I mentioned. For now I have just included code for the technique used in the demo.

Download: AS3 Webcam Motion Tracking
Read : AS3 Webcam Motion Tracking »

Posted on 06 Jun 2008
279 Comments
54 Trackbacks

array_count_values in Actionscript

In PHP there is a very useful function called array_count_values. It sorts an array by returning a 2 dimensional array consisting of non duplicate elements as keys, and values determined by how many times these elements appeared in the original array.

update 09.10.10

This can be achieved (in AS2 and AS3) in a much simpler manner, using the following function or prototype:

Array.prototype.countValues = function() : Array
{
	var i, j = -1, c, o = {}, r = [], v, n = a.length;
	for(i = 0;i < n;++i) (c = o[v = a[i]]) ? ++c[1] : r[int(++j)] = o[v] = [v,1];
	return r;
}

So, for example, an array [“red”,”green”,”blue”,”red”] would be converted into [“red” => 2, “green” =>1, “blue” => 1]. Duplicate elements are removed and the new array indicates how many times each, now unique value occurred in the array.

Unfortunately, Actionscript has no such function built in, so I made one. It is a modification of Senocular’s array.unique() prototype (which you can find in his Actionscript library), however rather than simply returning a unique array, it returns the 2 dimensional array mentioned above. Read : AS2 Array count values »

Posted on 20 Jun 2007
Posted in
Tagged
5 Comments
0 Trackbacks

Flash Dynamic Stacking Menu

Update: AS3 Version using TweenLite is available here

In this experiment, you can drag the boxes; when you release them the stack will shuffle to accommodate the dropped box.

I have recently been working on building an application in which I wanted to use Photoshop style ‘layers’ which the user could create, drag onto different depths and delete.

The basic idea was for the user to click and drag ‘layers’, and drop them in between others. This would cause the other layers to reposition to accommodate the new layer and to fill the gap which it had left in it’s old position. Get it? Read : Dynamic Stacking »

Posted on 13 Apr 2007
44 Comments
4 Trackbacks

Flash Liquid Layout Dynamic Positioning

Following another post regarding using stage listeners to dynamically resize and position MovieClips in Flash, I was asked to upload and FLA as an example. The previous code can just be pasted into the actions panel and will run without any MovieClips needed, and was designed to show the StageListener function rather than showcase a particular dynamic layout.

Download: Fluid Flash Layout Example Read : Dynamic Positioning Continued »

Posted on 08 Mar 2007
Posted in
Tagged
60 Comments
0 Trackbacks

Group94 Style Menu System

I have always liked the neat and compact menu system Group94 often use in their projects. It is really useful for lists or menus and is also of course very elegant.

I don’t know how Group94 do it, but here is my attempt. I have created two prototypes to make it easy to use multiple times within a project.

Download: Group94 Style Scrolling List Read : Group94 Style Menu »

Posted on 07 Mar 2007
Posted in
33 Comments
1 Trackbacks
  • Page 1 of 2
  • 1
  • 2
  • >

About me

Soulwire is a weblog by Justin Windle; a Senior Interactive Developer at Fi (Fantasy Interactive), Stockholm – I often Tweet, Flik, Link and Vim.

Warning: file_get_contents(http://search.twitter.com/search.atom?q=from:soulwire&rpp=1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 410 Gone in /home/soulwire/webapps/soulwire_blog/wp-content/themes/soulwire/functions.php on line 203