On the days of Flash 7 (and less), one of the biggest problems I had to deal with was handling a lot of objects on screen, at the same time. This was particularly true with painting pseudo-applications – you know, cutesy websites where you could create drawings within Flash. The problem with sites like that was that, after painting for a while, no matter how well you managed your MovieClips, the movie would become too unresponsive and too slow – and drawing with increasingly slower framerates was really annoying. This is specially true in websites like this and this (click on “Mande seu manifesto para a Triton” then on the spraycan): you could do a lot of cool stuff, but after a while, it became unbearable to work on the painting.
That’s where Flash 8 comes in. With the new BitmapData (and related) classes, you can avoid all the previous slowdown. The problem on Flash 7- is that you are dealing with very complex MovieClips on top of each other, and when adding new drawings to that, it’s only normal that your framerate will drop. With Flash 8, however, you can just create a copy of the existing drawings and work on top of that. I’m not talking about cacheAsBitmap; it would help, but not much. The best solution, instead, was getting rid of the MovieClip drawings entirely and save them as a BitmapData object instead.
That’s what I decided to try these days. While doing an school assigment for an art history class, I decided to do something based on Van Gogh’s impressionist work; the result is what I call Auto-Van-Gogh, a very raw painting application (around one day of work).
The cool thing about it, however, is that each time you let go of the mouse, the current drawing is converted to an image and added to the background image. Because of this, each new drawing will be as fast as the previous one; even though this application is, technically, much more demanding when drawing than my previous examples – it creates a lot more MovieClips – it’s still faster because it doesn’t have the increased letargy you’d have to deal with on Flash 7-. Try drawing this or this, for example – it’s what I used as a reference for the drawing code.
One problem with this new technique is the inability to work with individual MovieClips; on my Flash 7- websites, I could have an infinite level of undos – each undo simply removed the latest MovieClip created. On the Auto-Van-Gogh example, though, everything’s added to a single image, so there’s only one level of undo (an additional BitmapData copy I do on every new edition). This could be worked around, of course, with enough memory – you could keep copies of several levels of undo in memory, or even keep the raw MovieClips elsewhere and just flatten then as image on each new drawing.
All in all, though, these new techniques show the true potential of the new BitmapData class; when extending on stuff that was already possible with Flash, but not quite good enough. Right now, we can finally have painting quality as good as the one you’d expect to find on Zewall (which was done with Director) and still keep it as fast as when you started drawing.