Linestyle & beginfill going wacko!

When you use linestyle and beginfill to create a stroked rectangle:

   shape.graphics.lineStyle(thickness, borderColor, 0.4, false, LineScaleMode.NORMAL,CapsStyle.NONE, JointStyle.MITER, 10);
   shape.graphics.beginFill(0xff0000,0.5);
   shape.graphics.moveTo(0,0);
   shape.graphics.lineTo(0,h);
   shape.graphics.lineTo(w,h);
   shape.graphics.lineTo(w,0);
   shape.graphics.lineTo(0,0);
   shape.graphics.endFill();

… and change the thickness, it gives a rectangle of different widths. The stroke is very carelessly rendered (based on the thickness). I basically want the stroke to appear as an inner stroke, and no matter what stroke thickness is used, the overall width should look the same. Any ideas guys?