Hello,
I have a problem with drawing bitmapData in AS3 with an onEnterFrame action. It worked great in AS2, and now that I converted it to AS3, it’s bogging down on my system rather slowly… I’m using the dispose() method on both bitmapData instances I have, and I can only notice the slowness after about 10 minutes of playing it…
Hope somone has an insight about the issue. Here is a snippet of my code:
function enterFrameEvent(e:Event) {
makeKlydo();
}
function makeKlydo(){
stampImage = new BitmapData(this.myElement["k"+myElementObject].width, this.myElement["k"+myElementObject].height, true, 0xFFFFFF);
stampImage.draw(myElement, new Matrix(1, 0, 0, 1, this.myElement["k"+myElementObject].width/2, this.myElement["k"+myElementObject].height));
if (deceleration<1){
deceleration -= (deceleration-1)/5;
}
if (rotate1) {
r += rotspeed1 * fanning * deceleration;
}
if (rotate2) {
r2r -= rotspeed2 * fanning * deceleration;
}
if (rotate3) {
rot += rotspeed3 * fanning;
}
map.dispose();
map = new BitmapData(hsize, vsize, true, 0x00000000);
mapBM = new Bitmap(map);
mapHolder.addChild(mapBM);
for (var i = 0; i<slices; i++) {
m.identity();
m.b += sh1;
m.c += sh2;
m.rotate(r2r);
m.translate(myElement.width/2,myElement.height);
m.rotate(r);
m.scale(scl, scl);
slice.graphics.clear();
slice.graphics.lineStyle();
slice.graphics.moveTo(0, 0);
slice.graphics.beginBitmapFill(stampImage, m);
slice.graphics.lineTo(Math.cos((angle+nudge)-Math.PI/2)*diag, Math.sin((angle+nudge)-Math.PI/2)*diag);
slice.graphics.lineTo(Math.cos(-(angle+nudge)-Math.PI/2)*diag, Math.sin(-(angle+nudge)-Math.PI/2)*diag);
slice.graphics.lineTo(0, 0);
slice.graphics.endFill();
m.identity();
if (flip && i%2 == 1) {
m.scale(-1, 1);
}
//m.rotate(rot+i*angle*2*fanning);
m.rotate(rot+i*angle*2);
m.translate(hsize*0.5, vsize*0.5);
map.draw(slice, m, null, "normal", null, true);
}
stampImage.dispose();
}
addEventListener(Event.ENTER_FRAME, enterFrameEvent);
Thanks!
itai