ActionScript 3 Understanding the "Error 1009: Cannot access a property or method of a null object reference" Invalid typecast


function listener(e:Event):void {
    var as MovieClip;

If such a listener is attached to an object that's not a MovieClip descendant (for example, a Sprite), the typecast will fail, and any subsequent operations with its result will throw the 1009 error.