Using BitmapData.lock( ) to improve performance
package{
import flash.display.*;
public class Main extends Sprite{
public function Main(){
var imgData:BitmapData = new BitmapData(500, 500, true, 0x00000000);
var bmp:Bitmap = new Bitmap(imgData);
imgData.lock( );
var color:uint;
for (var i:int = 0; i < imgData.height ; i++) {
for (var j:int = 0; j < imgData.width; j++) {
color = Math.floor(Math.random( )*0xFFFFFFFF);
imgData.setPixel32(j, i, color);
}
}
imgData.unlock( );
}
}
}
Related examples in the same category