matrix (ConvolutionFilter.matrix property)

public matrix : Array

An array of values used for matrix transformation; returns a copy. The number of items in the array must equal matrixX*matrixY.

The matrix property cannot be changed by directly modifying the values (for example, myFilter.matrix[2] = 1;). Instead, as shown in the following example, you must get a reference to the array, make the change to the reference, and reset the value using filter.matrix = newMatrix;.

Availability: ActionScript 1.0; Flash Player 8

Example

The following example changes the matrix property of filter from one that blurs a bitmap to one that sharpens it.

import flash.filters.ConvolutionFilter;
import flash.display.BitmapData;
    
var filter:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9);

var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00FF0000);
    
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
myBitmapData.noise(128);
        
mc.onPress = function() {
    var newMatrix:Array = [0, -1, 0, -1, 8, -1, 0, -1, 0];
    filter.matrix = newMatrix;
    myBitmapData.applyFilter(myBitmapData, myBitmapData.rectangle, new Point(0, 0), filter);
}