03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Alpha only. When you pass to the filter a matrix that adjusts only the alpha component, as<br />

shown here, the filter optimizes its performance:<br />

1 0 0 0 0<br />

0 1 0 0 0<br />

0 0 1 0 0<br />

0 0 0 N 0 (where N is between 0.0 <strong>and</strong> 1.0)<br />

Faster version. Available only with SSE/Altivec accelerator-enabled processors such as<br />

Pentium 3 <strong>and</strong> later, <strong>and</strong> Apple G4 <strong>and</strong> later). The accelerator is used when the multiplier<br />

terms are in the range -15.99 to 15.99 <strong>and</strong> the adder terms a[4], a[9], a[14], <strong>and</strong> a[19] are in<br />

the range -8000 to 8000.<br />

A filter is not applied if the resulting image would exceed 2880 pixels in width or height. For<br />

example, if you zoom in on a large movie clip with a filter applied, the filter is turned off if the<br />

resulting image reaches the 2880-pixel limit.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Example<br />

The following example uses BitmapFilter to manipulate the color saturation of an image<br />

based on the location of the mouse pointer. If you position the pointer in the upper-left<br />

corner (0,0), the image should be unmodified. As you move the pointer to the right, the green<br />

<strong>and</strong> blue channels together are removed from the image. As you move the pointer down, the<br />

red channel is removed. If the pointer is positioned at the lower right of the Stage, the image<br />

should be completely black. This example assumes that you have an image in your library<br />

with its Linkage Identifier set to "YourImageLinkage".<br />

import flash.filters.BitmapFilter;<br />

import flash.filters.ColorMatrixFilter;<br />

var image:MovieClip = this.attachMovie("YourImageLinkage", "YourImage",<br />

this.getNextHighestDepth());<br />

image.cacheAsBitmap = true;<br />

var listener:Object = new Object();<br />

listener.image = image;<br />

listener.onMouseMove = function() {<br />

var xPercent:Number = 1 - (_xmouse/Stage.width);<br />

var yPercent:Number = 1 - (_ymouse/Stage.height);<br />

var matrix:Array = new Array();<br />

matrix = matrix.concat([yPercent, 0, 0, 0, 0]); // red<br />

matrix = matrix.concat([0, xPercent, 0, 0, 0]); // green<br />

matrix = matrix.concat([0, 0, xPercent, 0, 0]); // blue<br />

matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha<br />

var filter:BitmapFilter = new ColorMatrixFilter(matrix);<br />

ColorMatrixFilter (flash.filters.ColorMatrixFilter) 431

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!