Bill
Bill

Reputation: 19238

AS3 bitmap width vs draw shape (Performance)

Just a quick question, which way render quicker:

i would like to have a background set up (a sprite);

method 1

sprite.graphic.draw()
sprite.graphic.drawRect(0,0,100, 1024)

method 2: a png (original height 10px) and just make the height to 1024

sprite.addChild(Bitmap);
Bitmap.height = 1024;

Thanks for any suggestion

Upvotes: 0

Views: 605

Answers (1)

shaunhusain
shaunhusain

Reputation: 19748

As with the previous "performance" question, always best to test. My background knowledge (pun totally intended), tells me that the first method is better, in the second method you have to load the PNG decode it, scale it, in the first method you simply modify the pixels in memory that you need (can cache the Sprite using cacheAsBitmap).

More on cacheAsBitmap here: http://www.andymoore.ca/2010/09/cacheasbitmap-performance-testing/

Edit Per comments, a better solution

var bd:BitmapData = new BitmapData(100, 1024, false, 0xff00ff00);
var bmp:Bitmap = new Bitmap(bd);
addChild(bmp);

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#BitmapData()

Upvotes: 2

Related Questions