Antti Kupila

Personal Blog, Portfolio and Online playground

View over the green room at Sid Lee, Montreal

Slow motion flash for debugging

So, here's the deal. You're working on something in flash, you test several simultaneous scripted (or not) animations out and notice something's wrong. There's some weird overlapping or something going on there, but it's really hard to tell since it all happens so fast. Sure, you could leave it there as it's barely noticable, but we want to make products that aren't just good but perfect.

So, how do we solve this? Well, by now—since you've read the title—you probably know where I'm heading. Me and Svante from ACNE Digital (the company i worked for before) were talking about this and i decided that i'd come up with some slick solution that's easy and quick to use whenever this happens. So, that's what I did. And of course to support open sourcen and help other people make better products, you'll get it too. For free as always.

Recorder.as

The Recorder is a pretty simple class that let's you specify an area to record and then simply record that into RAM, which you can then play back at the desired speed. To keep it easy to share I put everything in one class, including the recorder, the playback, and the gui with an animation engine. This of course makes it more difficult/annoying to create & modify, but it's easier to download and use as it's only one file.

So, how do you use it?

Well, it's pretty simple. Place the class in a folder /com/anttikupila/debug/ in your classpath. Then just import the class, and call Recorder.initialize( );. That's it.

Actionscript:
  1. import com.anttikupila.debug.Recorder;
  2. Recorder.initialize( );

Here's an example with some motion graphics, courtesy of Alexander Petterson (thanks Alex!):

To try it out. Click inside it first to give it focus, press and hold space, then drag an area to record and click the area. Then press space again to stop recording and start playback. Adjust speed with the up and down keys or with the dial to the right. You can hide it again by clicking space, which obviously also frees all resources required (this thing's really ram-hungry). If you want, you can download the source to the example too.

There is really no limit on the length (except your ram/patience), but I'd keep it pretty short - basically just for the time you see the problem. After this it'll start playing those frames in a loop at the original speed. You can adjust the playback speed from the dial to the right.

Now I know some people will say that there's no timeline etc. But people, think about it; do you really need it? I don't think so, and it looks nicer like this :) Less is more, 'aye. Still, if you want, feel free to add additional controls (if so, please help everybody else and share the code).

Actionscript 2.0 only at the moment, sorry about that. Still, it's very easy to port to AS3 if you need to do so. Also i want to mention that this is something i made in like one or two days, so please don't use it in any production environment as it is. It's meant as a debug tool so bug threshold isn't the same as on production sites ;)

I'd love to hear your comments & suggestions

Enjoy :)

Comments

8 Comments
  1. 2007-08-09, 18:54 by MaX

    Amazing!!…
    I mean….that´s a pretty wild idea and solution you came up with.
    Contratulations.

  2. 2007-08-11, 17:49 by zoegirl

    Does not work in Safari. But very cool.

  3. 2007-08-14, 18:43 by Luke

    Thanks

    This looks awesome.

    Hope you’re digging SF

  4. 2007-08-20, 2:57 by Micheal

    Works in Safari for me and I’m pretty blown away. That’s an awesome and quite useful class.

  5. 2007-08-23, 9:21 by Thomas hyper norwegian

    Very nice!
    Cool ide and you pulled it off great
    there is a little bug when reducing speed though, I have
    to pull the slide bar over my whole screen too get i down by 10%
    but still very nice indeed :)

  6. 2007-08-26, 22:44 by Owen van Dijk

    Really, really cool idea and implementation! :)

  7. 2008-02-29, 0:10 by Seth Markowitz

    This is an interesting use of recording bitmapdata. Is there a way to record the audio in a similar way so you can fast-forward or fast-rewind and flv? WMP has this:
    http://msdn2.microsoft.com/en-us/library/bb262909(VS.85).aspx

    But I have yet to find anything similar for dealing with controlling the playback speeds of an flv…

  8. 2008-02-29, 0:17 by Antti Author comment

    Seth: Recording audio & playing it back in slow motion is a lot more difficult than with an image (mostly due to the lack of audio stuff you can do in flash). André Michelle has done some great audio stuff though and i’m guessing he might have stuff like this built in too (haven’t checked though). See http://code.google.com/p/popforge/

    Regarding the playback of FLV’s we did a project with this at AKQA last year allowing the user (among other things) to control the speed of an FLV. I’m currently rewriting the engine in AS3 and will post an article about it when i’m done. I don’t want to give away too much but i can tell you it’s pretty sweet ;)

Post a comment