I’m trying to make a loading bar using bitmaps, drawing with copyPixels one over another. But it seems that bitmapdata I use as an empty state is cached and modified even if I turn useCache off. So once it’s drawn with 50% for example it’ll not show less than this amount if I try to redraw it. On Flash taget the bar is showing the right amount but not on html5 target.
_filledBarPoint = new Point();
emptyBarSprBitmap = new Bitmap(Assets.getBitmapData("assets/emptBarRect.png", false));
fullBarSprBitmap = new Bitmap(Assets.getBitmapData("assets/fullBarRect.png", false));
emptyBarSprBData = Assets.getBitmapData("assets/emptBarRect.png", false);
barWidth = fullBarSprBitmap.width;
barHeight = fullBarSprBitmap.height;
barScaleRect = new Rectangle(0, 0, barWidth*0.5, barHeight);//start with 50%
emptyBarSprBitmap.bitmapData.copyPixels(fullBarSprBitmap.bitmapData, barScaleRect, _filledBarPoint);
addChild(emptyBarSprBitmap);
//clean it up
barScaleRect.setTo(0, 0, emptyBarSprBData.width, emptyBarSprBData.height);
emptyBarSprBitmap.bitmapData.copyPixels(emptyBarSprBData, barScaleRect, _filledBarPoint);
barScaleRect.width = barWidth * 0.1;//try to draw 10%
//draw full bar bitmapData on top again but with 10% of its width - on html5 still shows 50%
emptyBarSprBitmap.bitmapData.copyPixels(fullBarSprBitmap.bitmapData, barScaleRect, _filledBarPoint);