Making Leopard’s Quicklook Feature (more) Useful

I've been dealing with piles of two types of files that are somewhat awkward to work with on the Mac - ZIP files and EPS files. On the PC I can just double click on a ZIP file and peer into what's inside without actually unzipping it, on the Mac, not so much. When it comes to EPS files, I'll open then with preview and then get a lovely spinning beachball while it is "Converting Postscript to PDF...". Now admittedly it's faster on Leopard that it was on Tiger, but still, that sucks. Luckily these are exactly the kinds of problems Quicklook was made to handle.

If you haven't played with Quicklook, you just select a file and hit the spacebar - you then get a preview of the contents of the file. By default it works with iWork formats, and all the usual MS Office formats. The best part though is that third parties can write their own plugins for Quicklook - and developers have already made some for ZIP and EPS! Now I just select either file type and smack the spacebar and BAM! almost immediately I can peer inside of ZIP files or preview EPS files.

It's times like these I *really* love the Mac developer community (and Apple ain't half bad either, though I'm still not fully digging Stacks!).

The Nooks and Crannies of ActionScript 3

The slides from Branden's presentation at FITC Hollywood 2007, Flash on the Beach 2007, and FITC Winnipeg 2007 - "The Nooks and Crannies of ActionScript 3" are now available for download. Enjoy - and if you have any questions or comments drop us a line.

FITC Road Show - Winnepeg 2007

Branden will be speaking this weekend at The FITC Road Show - Winnepeg 2007. This will be Branden's first time in Winnepeg and he's hoping to not lose any vital body parts to frostbite!

The notes from his talk "The Nooks and Crannies of ActionScript 3" will be available on the site soon.

Chaining Events

Lately I've been dinking around with a wonderful library for Python called Twisted. Twisted is a networking library that makes creating custom clients and servers insanely easy.

Like a lot of good libraries Twisted starts off with a philosophy (think Ruby on Rails, etc) - in Twisted's case it's "You don't call Twisted, Twisted calls you". If that immediately makes you think "hey they must be doing some neat things with events!" then you're right.

When you're using Twisted and you call a function that needs to do some sort of work where it will takes some time for the result to be available you don't have to wait for that result to come. Instead the function immediately returns an instance of the Deferred class. What is the Deferred class you ask? Well, I think the Twisted manual explains it best:

Twisted uses the Deferred object to manage the callback sequence. The client application attaches a series of functions to the deferred to be called in order when the results of the asychronous request are available (this series of functions is known as a series of callbacks, or a callback chain), together with a series of functions to be called if there is an error in the asychronous request (known as a series of errbacks or an errback chain). The asychronous library code calls the first callback when the result is available, or the first errback when an error occurs, and the Deferred object then hands the results of each callback or errback function to the next function in the chain.

I happen to think that's a pretty neat take on chaining events and am seriously debating creating a similar system for a new little project I'm working on that will involve a lot of async programming.

In general finding this concept reminds me about why it's so important to go outside of your usual mental playground and find other places where developers are playing. Almost every time I do this and go look at something like Python or Objective C or Haskell I end up finding a concept I want to port over to one of my usual tools.

How do I do “onReleaseOutside” in ActionScript 3?

Back in the days of ActionScript 1 and 2 you sometimes wanted to find out when a button or movieclip was clicked, but then the mouse was released outside of that object. This was particularly handy when doing drag and drop since it was (and still is) possible that the user could whip their mouse around and let go of the mouse when the mouse pointer wasn't actually on top of the clip. If you didn't listen for the the "onReleaseOutside" event the clip being dragged would now be permanantly stuck a few pixels away from your mouse pointer following it around like a stray dog.

In ActionScript 3 the core mouse related events are CLICK, MOUSE_DOWN, and MOUSE_UP. The overall concept of releasing the mouse but not on top of the display object that received the original MOUSE_DOWN event is intrinsically handled by how the new event system works. Essentially events go through phases - for example when the mouse is pressed the Flash player creates an event and passes that event down from the stage through the display tree to the display object that was actually clicked on. If that display object doesn't catch the event it then bubbles back up the tree to see if any of those display objects want to handle it. If the event bubbles all the way up the stage and it isn't handled it is just destroyed.

Thus, you can find out when the mouse was released, no matter what display object it was over, by listening for a MOUSE_UP event coming from the stage. Just as always you should only listen for this event when you need it - which in this case is easy to do because you can start listening when the the MOUSE_DOWN event is handled and stop listening when the MOUSE_UP event is handled.

import flash.events.MouseEvent;

function dragPin(evt:MouseEvent):void {

pin.startDrag();

stage.addEventListener(MouseEvent.MOUSE_UP, dropPin);

}

function dropPin(evt:MouseEvent):void {

pin.stopDrag();

stage.removeEventListener(MouseEvent.MOUSE_UP, dropPin);

}

pin.addEventListener(MouseEvent.MOUSE_DOWN, dragPin);

Holy cow! This is a cool website!

I'm sorry, that wasn't in the form of a question - but thank you! The site was designed and developed by the fine folks at Parlour. They also did all of our branding work and are some of our favorite people to work with.

The site is based on WordPress and is hosted by Huevia.

Welcome to Automata Studios.

Welcome to the new home of Automata Studios, we're glad to have you here.

Take a minute to browse around and check out some of the new features. We have some code examples and upcoming speaking gigs in the sandbox for you to play with, and for an aggregate list of our content, and a great place to pull an RSS feed some, check out our testing ground, Automata Labs.