ProblemYou want to detect the edges of a display object. SolutionUse an edge detection matrix with a convolution filter. DiscussionTo apply an edge detection effect with a convolution filter, use a matrix with a negative value in the center surrounded by a symmetrical set of positive values, as described in the following generic matrix: a b c d e d c b a The following matrix applies a generic edge detection effect: 0 1 0 1 -3 1 0 1 0 The following applies the preceding edge detection effect to a display object: sampleSprite.filters = [new ConvolutionFilter(3, 3, [0, 1, 0, 1, -3, 1, 0, 1, 0])]; The greater the center number, the less edge detection is applied. The following uses a center value of -1 with a divisor: sampleSprite.filters = [new ConvolutionFilter(3, 3, [0, 1, 0, 1, -1, 1, 0, 1, 0], 3)]; See AlsoRecipe 10.6 |