Getting alpha to work in canvas

I discovered that alpha values applied to display objects didn’t work in the canvas version of the HTML5 version of my game. After much trial and error, I learned that simply adding a filter solved my problem. If the display object has an alpha matrix filter applied, then any alpha setting between 0 and 1 works.

var matrix:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var alphaFilter:ColorMatrixFilter = new ColorMatrixFilter(matrix);
myDisplayObject.filters = [alphaFilter];
myDisplayObject.alpha = 0.5;