Filling a custom shape

Hi,

I have made an app that draws shapes using the lineTo method to create a pen like effect. I then want this shape to be filled like the bucket tool in photoshop/flash. I tried to use beginFill but it doesnt seem to work.

Does anyone know of a good tutorial to do such a thing?

Thanks