Lanny McNie

As the dev mgr, Lanny oversees the technical day-to-day details of production and makes sure things get out the door.

@astrostyle

ColorMatrix Class in AS3

Something I’ve been meaning to do for a while now is port our ColorMatrix class to AS3. It’s a fairly simple conversion, but is still a handy utility to have on hand.

If you haven’t used the ColorMatrix class before, here is the description from when we first released it in 2005:

ColorMatrix provides a way to adjust Brightness, Contrast, Saturation and Hue based on a range of numeric values as well as multiply matrices. The ColorMatrix can then be passed into ColorMatrixFilter to apply color adjustments. The added bonus of ColorMatrix is that it uses the same calculations to generate matrix values as the Flash 8 IDE (with the exception of contrast adjustment which uses linear interpolation to provide a bit more granularity).

Download the updated source here

Here is a quick sample of it in use. This demo is included in the download package.

Continue reading →

CS3 Component bug: Component Styles

I was reminded a few weeks ago by Phil Chung (of philterdesign fame) of a bug in the CS3 component framework which we encountered shortly after CS3 was released.

Basically it boils down to setting component-level styles before any components of that type have been created. The styles are created, but when the first component of that type is instantiated, it resets the component styles, and overwrites the changes that were made beforehand. Slap a button in the library of a new FLA, and add the following code:

import fl.controls.Button;
import fl.managers.StyleManager;
var tf:TextFormat = new TextFormat();
tf.color = 0xff0000;
StyleManager.setComponentStyle(Button, "textFormat", tf);
var b:Button = new Button();
addChild(b);

There is an easy workaround, which is to make sure you set component styles *after* a component of that type has been instantiated. You can also just create a dummy instance of the component, and destroy it (which properly creates the style definition) and eliminate the issue.

You can download this fix here. One thing to note is that the components do not compile based on the component source code that is included with CS3, but rather the compiled componentShim component included in each component. To use this updated class, drop it in the appropriate directory (fl/managers) relative to your project, or in any path that is part of your publish class paths. The components will prefer any class definition found locally over the componentShim.
Please note that this is not officially supported by Adobe, and we take no responsibility for its use.

So there you have it. I imagine at some point, an updated release of the components will solve this and other issues, but until then at least this issue is resolved.

Branching Experiment: Flaming Hairball

After having my creative mojo refueled at Flash on the Beach, I’ve started playing around with some of my old experiments again. One of my favourite older experiments is my vein logic – it’s just such a beautiful example of recursion, and can be applied to so many things (like veins, vines, trees, more trees, and lightning) – so I decided I would rewrite and rearchitect it for ActionScript 3.

I barely managed to lay the groundwork for the new architecture before I got sidetracked by the file I was using to test it, and wound up building what I will affectionately call the Flaming Hairball.

You can check it out below.

Continue reading →

SPL Tricks: Powerful Multi-Purpose Text Highlighter

One of the things I put a lot of work into for Spelling Plus Library was architecting it in a very modular, extendable fashion. The main reason for this was to allow developers to use it in the way that makes most sense for their projects. For example, Buzzword only uses the SpellingDictionary class, which handles all of the spell checking and spelling suggestion logic, and the WordListLoader, but manages the user interface themselves.

A secondary benefit is that many of the classes are very useful on their own. The best example of this is the TextHighlighter class that forms the core of the SPL SpellingHighlighter. It is a very powerful class for finding and highlighting words in a text field in real time.

It includes a ton of features, including support for manual selections, multi-line highlights, smart targeting, autoupdating on change and scroll, interactive highlights, and more. It will be gaining even more functionality in the upcoming 1.1 release of SPL.

Continue reading →

Squeeze Effect Source Code

One of the limiting factors for how much code I release has always been the need to clean up and refactor the code before I make it public. After thinking about it a bit, I decided in the interest of sharing more with the community I would start releasing some of my simpler “proof of concept” type experiments without polishing them first, starting with this one.

A little over a year ago, I put together a simple OSX-esque squeeze effect to transition in dialogs in one of our projects. It never saw the light of day, but I stumbled on the proof of concept yesterday and thought I should share it. It uses DisplacementMapFilter and a simple tween.

Here’s what it looks like:

Continue reading →