Line drawing animation against gradient background

Hi,

This is my first post, so I hope I am in the right place.

I am creating an animation in Flash. The characters are line drawings, so they have no fill; in other words, they are transparent between the lines.

The background is gradient.

The problem is, that when the characters pass by each other, I can see through the character on top to the character underneath.

My first thought was to add fill to the character on top, but then it no longer looks like a line drawing, because the background changes shades as he walks from the left to the right.

Can anyone point my in the right direction? I just want to have the line drawing show the gradient background, but not the other character it passes by (or over).

I was thinking of creating a separate movie clip of the character walking from left to right by himself, over the same gradient. Then maybe masking the background outside the lines out, so it’s just the character with the gradient changing inside its lines, then adding that movie clip to the original so it matches up, but I’m still a little confused about how masking works.

Anyway, hope someone could help, I am too far into the project to turn back now.