I've currently been trying to make a drawing application in flash and have sort of hit a wall with the brush tool. What I am trying to achieve is have the brush tool draw a texture.
Like this:

I thought I could see several ways to do it. But my biggest problem is I want to be able to keep all pixels on one bitmapData so I can export it later. Also the transparent areas need to remain transparent on export.
How I think it should work is something like this. Load in my tileable image and tile the image to a sprite, in this case the stage.

PHP Code:
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedGrass);
loader.load(new URLRequest("grass.gif"));
private function loadedGrass(e:Event):void {
bmp = new BitmapData(loader.width, loader.height);
bmp .draw(loader);
graphics.beginBitmapFill(bmp );
graphics.drawRect(0, 0, 550, 400);
graphics.endFill();
}
I've been testing with loading in an external image for the next part. In the final version I will draw black pixels directly to a bitmapData.
So next I load in a premade transparent image with black pixels in the spots I want to be visible.

PHP Code:
loaderTwo = new Loader();
loaderTwo.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedBlack);
loaderTwo.load(new URLRequest("black.png"));
This is the part I'm confused with. I think I'm supposed to use bitmap threshhold but not sure how.
PHP Code:
private function loadedBlack(e:Event) {
threshImg = new BitmapData(loaderTwo.width, loaderTwo.height);
threshImg.draw(loaderTwo);
bmp.threshold(threshImg,new Rectangle(550,400), new Point(),">=",0x000000FF, 0x000000);
}
Too get this result:

Am i going about this the wrong way. I feel like I'm doing the threshold on the wrong image, and not even sure on the values.
Is there a better way to achieve this effect.
2 Other ways I thought I could do this are
1. Do it is using masks but I didn't think that I could save an image with transparent areas from this.
2. Looping through all the pixels in the brushes radius when the mouse moves, check that they are black and using copy pixels off a texture that is tiled at the size of the stage.
Any thoughts? Actually after writing this post I'm thinking the later. But seems a waist not to post this