you can get close by applying the lens flare to a black layer (like you most likely have already). do a select all and copy, then add a layer mask to that layer.
go to the channels panel/tab, select the layer’s mask channel and paste.
go back to the layers panel/tab and apply the layer mask to the layer. then choose layer>matting>remove black matte.
it will do a pretty good job of giving you a keyed lens flare.
sometimes you can get better results by looking at the different color channels, then copy/pasting the color channel that looks like the best matte into the layer mask, it depends on the colors in the lens flare.
Thanks to Trish Meyer, who just showed me this recipe.
Todd Kopriva, Adobe Systems Incorporated
putting the ‘T’ back in ‘RTFM’ : After Effects Help on the Web
If a page of After Effects Help answers your question, please consider rating it. If you have a tip, technique, or link to share—or if there is something that you’d like to see added or improved—please leave a comment.