AS3 Benchmark: Graphics.beginBitmapFill() vs BitmapData()
Just worked on a racing game…
It requires lots of graphics and bitmaps. I have just discovered the other way how to render bitmaps in the flash.
Before, I’m using BitmapData and insert it in Bitmap, then add it in the stage. Just a while ago, I tried to use the Graphics.beginBitmapFill(). First, I did some benchmark and this how it was:
- using BitmapData:
var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000); var bmp:BitmapData = new BitmapData(100,100, false, 0x000000); for(var i:int = 0; i < 10000; i++){ bmp.draw(bmpData); }
- using Graphics.beginBitmapFill()
var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000); var shp:Shape = new Shape(); for(var i:int = 0; i < 10000; i++){ shp.graphics.beginBitmapFill(bmpData); shp.graphics.drawRect(0,0,100,100) }
This gave me 17ms for Graphics.beginBitmapFill() and 93ms for Bitmapdata()
So I’m suggesting now to use Graphics.beginBitmapFill() for bitmap patterns.
RSS feed for comments on this post. TrackBack URI

