Sixsided
Interactive Dev in Portland, OR

Adobe Flash CS6 makes some of its authoring functionality programmable via a Javascript API called JSFL. It's not especially fun to work with, as it lacks a debugger or any other tooling, but being able to create custom drawing tools was irresistable. Hence:

The Cube and Word Balloon Tools

animated gif of custom Flash tools
download the source

The API I spent the most time scratching my head over was fl.drawingLayer, which is used for rendering the temporary outlines that appear when (for example) you're dragging out a box with the Rectangle tool. It has some quirks.

  • It seems to maintain an internal array of drawing commands, which you can add to by calling moveTo, lineTo, quadraticCurveTo, etc.
  • fl.drawingLayer.beginFrame clears this array.
  • fl.drawingLayer.endFrame draws the contents of this array to the screen.
  • fl.drawingLayer.beginDraw , according to its documentation, "puts Flash in drawing mode", and sets the Boolean persistentDraw option, which will cause flash to leave your drawing on the stage after the mouse button is released. In practice it seems to make no difference.
  • It draws single-pixel, aliased lines in XOR mode (ie inverting whatever’s underneath), so if you accidentally draw a line twice inside the same beginFrame/endFrame scope, you won't see anything.
  • The up/down state of the mouse button appears to affect whether anything is drawn.