Use Cake

Use Cake is a showcase for stuff Joe Wheeler makes. Most of it is Flash / ActionScript development, with other random stuff thrown in. It’s a bit like a fruit cake, without any fruit, or cake.


Ok, last weeks mix was a great distraction, but my attention is now back on AS3 programming. In particular a very nifty feature of Flash, that is quite tricky to make work.

DisplayObject.scrollRect is a slippery eel of a construct. A scrollRect provides a great way to make sprites, movieclips and bitmaps scroll really efficiently but finding the full height or width of the unmasked content is a total pain in the neck.

Jon Williams posted an interesting idea, using transform.pixelBounds. Which actually gets most of the way to a solution, but it all goes horribly wrong when the any of the parent objects are scaled and/or rotated. It also finds weird values when the object is off the display list (always x5 the actual value).

But as Jon's idea seems to be the only one on the table, and I don't want to step back to regular masks, here's a couple working solutions:

A simple, hacky approach could be: remove the object from the display list, measure it, then put it back. As Jon pointed out in his post, the values are five times larger than expected, so we'd have to divide the result by five. The problem I have with is approach is, it will cause the object to fire a bunch of events we really don't want it to.

So, we're forced to go the long way round with something like this:

1. Save the objects transformation matrix in a local var
2. Get the objects concatenated transformation matrix and invert it
3. Set the objects transform to the inverted matrix
4. Measure the objects pixel bounds
5. Restore the original transformation matrix

Which could look something like...

/**
 * This function works like DisplayObject.getBounds(), except it will find the full
 * bounds of any display object, even after its scrollRect has been set.
 *
 * @param displayObject - a display object that may have a scrollRect applied
 * @return a rectangle describing the dimensions of the unmasked content
 */
public function getFullBounds ( displayObject:DisplayObject ) :Rectangle
{
	var bounds:Rectangle, transform:Transform,
	                    toGlobalMatrix:Matrix, currentMatrix:Matrix;
 
	transform = displayObject.transform;
	currentMatrix = transform.matrix;
	toGlobalMatrix = transform.concatenatedMatrix;
	toGlobalMatrix.invert();
	transform.matrix = toGlobalMatrix;
 
	bounds = transform.pixelBounds.clone();
 
	transform.matrix = currentMatrix;
 
	return bounds;
}

Phew, all that to get the height of the masked content. You have to wonder, if it's really worth it...


Here's a house mix I put together a little while ago. I'd been holding it back, looking for the right starter. Moment is just about perfect, so here's the mix -- deep with acidy bits.

Get it on iTunes or download the mp3.

Like most of my mixes, it was put together in total darkness while my family was safely tucked in. Late in the night Daddy's such a rebel! 

Here's the flow:

  1. Moment - Damian Lazarus
  2. Crashing - Let's Go Outside
  3. Out There - Friends of Matthew
  4. Downtime - Paper Music
  5. Aldie - Marcel Wave
  6. Mad About (Rob Mello's 'No Ears' Mix) - Soild Groove
  7. You Are We (Ian Pooley's 'We Won't Give It Up' Dub) - Crazy Penis
  8. Ratman (Jay Haze Edit) - Minimono
  9. Enerverende - Federico Molinari
  10. Outta Limits - Mission Control
  11. The Bigger Man - Chupacabra
  12. Attend 1 - DJ Gregory
  13. Swim (Peter Dildo Swimming In Deep Water Remix) - Matthias Tanzmann
  14. Disco Africa (Quantic Mix) - The Ogyatanaa Show Band
  15. Make It Don't Fake It - Neighbour
  16. As Time Goes Bye-Bye - Roman IV
  17. Mushrooms (Justin Martin Remix) - Marshall Jefferson
  18. Cycles - Dan Ghenacia
  19. Rabouine House (Dyed Soundorom Tropical Remix) - Anthony Collins
  20. Time Fades Away (Daniel Stefanik Remix) - D.Ramirez & James Mowbray

I can never play Outta Limits without giving due props to Matt Patterson. He blew me away with it in '92 and it's been a firm favourite ever since. Will that record ever get old?

I'll probably post a few more mixes over the coming months so stay tuned.


I've almost finished entering content into the Portfolio section of this site. And phew, there's quite a lot of it. But then, I have been building this stuff for over a decade. I thought it would be a good idea to highlight a few of the projects I'm most proud of. I've decided to put together a series of Best of round ups.

I'm doing more technical work that anything else right now, so for this one I've picked the three projects I'm most proud of from a technical point of view. And here they are:


Firecrackers (Interactive)

Firecrackers (Interactive)

So after ten years of building websites for others, I've finally got it together to build my own. To celebrate, here are some firecrackers.

I've been doing a lot of messing about with particle systems recently. This piece was the result of exploring chain reactions. It's a bit rough around the edges but I quite like the effect. The collision detection is managed with a quadmap; each quad contains a linked list of colliders. For speed, no narrow phase collision checking is done. The example here has about 1k particles, I've had about 2.5k running before my machine starts to struggle (last years MacBook Pro). For those of you that do, here's the source .