Please help - drawing a transparent BitmapData error

Hey all,

I have a huge background bitmapdata with a corresponding grid. I’m trying to draw the two parts onto a different bitmapdata, but for some reason, the bitmap for the grid is overriding the bitmapdata of the background that is being drawn first. The grid seems to be making the entire third bitmapdata transparent for some reason.

My code for creating the background and corresponding grid:


viewWidth=stage.stageWidth;
viewHeight=stage.stageHeight;
            
bmdScreen=new BitmapData(viewWidth,viewHeight,true);
screen = new Bitmap(bmdScreen);
addChild(screen);
            
var w:int;
var h:int;
            
bmdBackground=new BitmapData(roomWidth,roomHeight);
for (w=0;w<roomWidth;w+=bmdSheetBackground.width) {
   for (h=0;h<roomHeight;h+=bmdSheetBackground.height) {
      bmdBackground.copyPixels(bmdSheetBackground,new Rectangle(0,0,bmdSheetBackground.width,bmdSheetBackground.height),new Point(w,h));
   }
}
            
var size:int;
var rows:int;
var columns:int;
            
size=32;
rows=roomWidth/size;
columns=roomHeight/size;
            
shapeGrid=new Shape();
shapeGrid.graphics.clear();
shapeGrid.graphics.lineStyle(2,0x00FFFF);
            
// draws columns
for (w=0; w<columns; w ++)//draws columns
{
    shapeGrid.graphics.moveTo(w*size,0);
    shapeGrid.graphics.lineTo(w*size, rows*size);
}
for (h= 0; h<rows; h ++)//draws rows
{
    shapeGrid.graphics.moveTo(0,h*size);
    shapeGrid.graphics.lineTo(columns*size, h*size);
}
            
shapeGrid.graphics.moveTo(0,0);
shapeGrid.graphics.lineTo(1000,1000);
            
bmdGrid=new BitmapData(roomWidth,roomHeight,true,0x000000);
            bmdGrid.draw(shapeGrid);

And, my code for drawing the two parts:


// draw the screen
bmdScreen.copyPixels(bmdBackground,new Rectangle(viewX,viewY,viewWidth,viewHeight),new Point(0,0));
// draw the grid
bmdScreen.copyPixels(bmdGrid,new Rectangle(viewX,viewY,viewWidth,viewHeight),new Point(0,0));

As usual, I’m sure this is an easy problem, but my inexperience is working against me.

To put my problem simply:

I want to draw a grid on top of the background I have. For some reason, the grid is making the background underneath it transparent.

Thanks all!