I’ve been working with AS3 now for a few months and am making good progress in it (I’m a AS2 transfer student). However, on a project I’m working on I’m having a little issue with performance within the browser. I was wondering if anyone had some tips on how to optimize the following code as I include this object about 600 times in my flash to make a waterfall (which causes resource drain in the browser)?
package{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
public class waterfall extends MovieClip{
var myBlur:BlurFilter = new BlurFilter();
public function waterfall(){
this.y = findXY(0,160);
this.x = findXY(141,443);
this.blendMode = BlendMode.OVERLAY;
this.alpha = 0.55;
myBlur.quality = 3;
myBlur.blurX = 2;
myBlur.blurY = 2;
this.filters = [myBlur];
this.addEventListener(Event.ENTER_FRAME, moveWaterfall);
}
function moveWaterfall(e:Event):void{
this.y += 3;
if(this.y > 165){
this.y = -(findXY(0,165));
this.x = findXY(141,443);
}
}
function findXY(W:int, Z:int):int{
return Math.round(Math.random()*(Z-W))+W;
}
}
}