Fit DisplayObject into Rectangle

Actionscript 3.0 | 26 May 2009 | 11 comments

Actionscript 3.0 | 26 May 2009 | 11 comments

Fit DisplayObject into Rectangle

Utilities for Creating Thumbnails & Resizing

Fit DisplayObject into Rectangle

We’ve all been there. You’re building an image gallery and you need to create consistently sized thumbnails from a set of images, of various sizes and orientations and with differing aspect ratios - or you need a fullscreen background which always fills the stage, regardless of a user’s screen resolution and browser window size - or maybe you just need to fit a DisplayObject into a rectangular area whilst maintaining the correct proportions of the original image. // Read More

Flipping you the Boid

Actionscript 3.0 | 05 May 2009 | 30 comments

Actionscript 3.0 | 05 May 2009 | 30 comments

Flipping you the Boid

AS3 Flocking and Steering Behaviors

Flipping you the Boid

[Update 02.07.09]

I’ve uploaded the Boid source code. Sorry for the delay.

I’ve also included some basic examples of how you can create nice behaviors using the Boid class. If you set Main.as as your document class then you’ll see that within that you can specify the demo to run when you compile.

The basic demos included are:

  • Chase - Boids chase each other
  • Flock - Boids flock together with some wander
  • Graphics - How to use custom graphics with a Boid instance
  • Seek - Boids seek the mouse position
  • Wander - You guessed it, they wander

I’ve commented all of the methods and properties and there is also documentation (open index.html in the docs folder) to get you started.

Before you mention it, yes, there is some redundant code ;) (such as the constrainToRect method which doesn’t really work) but I need to do some optimisations anyway so I just left it as is for now, rough and ready.

Download the Boid class and demos

[End of update] // Read More

AS3 Shuffle Grid Class

Interfaces | 04 Mar 2009 | 36 comments

Interfaces | 04 Mar 2009 | 36 comments

AS3 Shuffle Grid Class

Drag & Drop Shuffling Grid Menu

AS3 Shuffle Grid Class

Click and drag the images around to rearrange the grid // Read More

Two Sided 3D Plane in FP10

Actionscript 3.0 | 30 Dec 2008 | 61 comments

Actionscript 3.0 | 30 Dec 2008 | 61 comments

Two Sided 3D Plane in FP10

Creating Double Sided 3D DisplayObjects

Two Sided 3D Plane in FP10

Flash Player 10 is required to view the demo

Download the PaperSprite class (Updated 09.01.2009)
With it you can easily create two sided 3D DisplayObjects using Flash Player 10 and the new 3D API… // Read More

Perlin Noise Flow Field

Actionscript 3.0 | 14 Dec 2008 | 24 comments

Actionscript 3.0 | 14 Dec 2008 | 24 comments

Perlin Noise Flow Field

Flocking Behaviours using Perlin Noise

Perlin Noise Flow Field

Download the source code of this demo…

It was a rainy Sunday and I found myself playing around with perlin noise for a couple of hours.

The idea was to create a simple flow field using the BitmapData perlinNoise method, and use this to influence the movement of autonomous agents. There is no complex vector math or steering behaviours, just some simple logic for how a particle or agent reacts to the current pixel it is positioned over. // Read More

Masking Transparent Bitmaps

flash | 10 Dec 2008 | 9 comments

flash | 10 Dec 2008 | 9 comments

Masking Transparent Bitmaps

Transparent Bitmaps & Gradient Alpha masks

Masking Transparent Bitmaps

Original image by Edwin Tofslie

I was having a few gradient alpha mask disabilities today and thought I should share my misery and consequential solution with anyone who might run into the same problems! // Read More

AS3 G94 Circular Menu

Actionscript 3.0 | 06 Nov 2008 | 47 comments

Actionscript 3.0 | Interfaces | 06 Nov 2008 | 47 comments

AS3 G94 Circular Menu

AS3 version of the Circular Group94 menu

AS3 G94 Circular Menu

Download the source code (Demo included)

I’ve received quite a few requests to update my circular group94 style menu to AS3 // Read More

BitmapData Colour Palette

Actionscript 3.0 | 11 Oct 2008 | 29 comments

Actionscript 3.0 | 11 Oct 2008 | 29 comments

BitmapData Colour Palette

Extracting the colour palette from an image

BitmapData Colour Palette

Update (20 April 2009) Uploads are temporarily not working as my server configuration has changed. I’m working on a fix and will have an update ASAP.
This is now fixed, but Flash Player 10 is required to view the demo

My previous post explained and provided a very simple method for extracting colours from a BitmapData image, by averaging the colours in specific areas.

This can have several applications, for example it features in a large amount of prototypes for the update to my Motion Tracking engine. However, if you want to create an accurate and representative colour palette from an image it has several flaws, the most obvious being that by averaging colours, you are actually removing or diluting the striking but perhaps less frequent colours in the image – the very colours which often make an image’s colour palette so exiting!

So, if we’re to extract an exciting and more representative palette from an image, we need a more intelligent algorithm; one which takes into account what makes a colour palette interesting – the contrasts and juxtapositions of colours within the image. // Read More

BitmapData Average Colours

Actionscript 3.0 | 10 Oct 2008 | 18 comments

Actionscript 3.0 | 10 Oct 2008 | 18 comments

BitmapData Average Colours

Finding the average colours in an image

BitmapData Average Colours

Update (20 April 2009)Uploads are temporarily not working as my server configuration has changed. I’m working on a fix and will have an update ASAP.
This is now fixed, but Flash Player 10 is required to view the demo

If you want a very simple way of extracting a colour palette from an image, one technique would be to average the colour values within specific areas.

Averaging colour values is almost identical to averaging numbers, except with the added initial step of finding the red, green and blue components of the colour. To do this we can use bitwise operators, in this case bitwise shift, to perform fast operations on each bit inside the unsigned integer returned by getPixel or getPixel32. If you want to know more about bitwise operators, Moock has written a detailed and, as ever, very clear article on where, when and why to use bitewise operations. You can read it here.

So once you’re familiar with how to shift the bits of an integer, you can easily get the RGB values from a 24 bit hexadecimal by moving the bits to the right by a certain amount using the bitwise right shift operator (>>). // Read More

3D Ribbons in Papervision

Papervision3D | 12 Aug 2008 | 40 comments

Papervision3D | 12 Aug 2008 | 40 comments

3D Ribbons in Papervision

Ribbon3D class for 3d lines and ribbons in PV3D

3D Ribbons in Papervision

There’s been some great experimentation with 3d lines and ribbons in Papervision3D, notably Felix Turner’s Ribbon3D and of course the Audi A5 website.

A project I’m currently working on requires the drawing of ribbons in 3D space, and it’s such a simple yet beautiful effect that I thought it was time to have a quick go at it myself. // Read More