Chapter 10. Filters and Transforms

Introduction

ActionScript lets you to apply several different transforms and filters to display objects (and bitmaps) to change their color, shape, rotation, size, and to apply special effects. Transforms are changes in color, shape, rotation, and size. The remainder of special effects di scussed in this chapter use filters. Filters are native to Flash Player; they allow you to apply effects ranging from blurs to embossing.

Applying Color Changes

Problem

You want to apply a color to a display object.

Solution

Assign a flash.geom.ColorTransform object to the display object’s transform.colorTransform property.

Discussion

Every display object has a transform.colorTransform property. The colorTransform property is a flash.geom.ColorTransform object that determines which color transforms are applied to the object. The colorTransform property always returns a copy of the actual ColorTransform object applied to the display object. That means that you cannot directly change the properties of the colorTransform property. You can, however, retrieve a copy of the actual ColorTransform object by assigning the value from the colorTransform property to a variable. Then you can change the properties of that copy and reassign it to the colorTransform property, as shown in the following example:

var color:ColorTransform = sampleSprite.transform.colorTransform;
color.rgb = 0xFFFFFF;
sampleSprite.transform.colorTransform = color;

The ColorTransform class defines two ways ...

Get ActionScript 3.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.