I was having problems setting a Bitmap’s width and height, and I think I may have found an issue that appears to be related to this. In the Bitmap class the width and height setters are of the form:
@:noCompletion private override function set_width(value:Float):Float
{
if (__bitmapData != null)
{
if (value != __bitmapData.width)
{
__setRenderDirty();
scaleX = value / __bitmapData.width;
}
return value;
}
return 0;
}
The problem arises when trying to set the width or height of an already scaled Bitmap to the same value as the width or height of that Bitmap’s bitmapData. If I understood this correctly, in this case the setters will ignore the given input value (“if (value != __bitmapData.width)”), thus the Bitmap’s scaleX or scaleY member (which is already != 1.0) will remain unchanged, and as a result the width or height of the Bitmap will not correspond to the given value.
I was able to correct the problem in my program by using the Bitmap’s scaleX and scaleY members directly instead of using the Bitmap’s width and height setters.