Adding a glow filter

AS3 allows us to dynamically apply a wide range of filters to DisplayObjects on the fly. We'll add a glow filter to simulate old 'arcades' pixel luminosity.

flash.filters.GlowFilter class lets us apply a glow effect to DisplayObjects.

First, we need to import it.

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;

at this time, we can simply create a new variable to construct a GlowFilter object. Change placeSpaceship this way:

private function placeSpaceship():void {
...
var glow:GlowFilter=new GlowFilter(0x00FFFF,1,6,6,2,2);
spaceship.filters=new Array(glow);
}

In the constructor I specified the color (0x00FFFF = the same cyan I used to draw the spaceship), ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.