I was working on a little particle engine for blood in a project im working on and i can see it being versitle enough to be good but when i import it into a test environmet it causes a little fps lag i was wondering if you as3 coding genius’s out there could help me out.
package {
//
import flash.display.Sprite;
import flash.events.Event;
//
public class mc_Blood extends Sprite{
//
private var xTarget:Number, yTarget:Number;
//
public function mc_Blood(gunRotate:Number, xSpawn:Number, ySpawn:Number, force:int):void{
//
cacheAsBitmap = true;
var i:int = 0
while(i<force){
var randomNum = ((Math.random() * 10)-5);
alpha = Math.random();
cacheAsBitmap = true;
var radia = Math.random();
scaleX = radia;
scaleY = radia;
x = xSpawn + randomNum;
y = ySpawn + randomNum;
xTarget = (Math.random() * 10);
yTarget = (Math.random() * 4);
rotation = gunRotate + randomNum
i +=1
addEventListener(Event.ENTER_FRAME, enterFrame);
}
}
public function enterFrame(e:Event){
alpha -= 0.005
scaleX -= scaleX / 100;
scaleY = scaleX
//
this.x += xTarget;
this.y += yTarget;
yTarget += 1;
if (alpha<=0) {
removeEventListener(Event.ENTER_FRAME, enterFrame);
stage.removeChild(this);
}//if{}
}//onTick{}
}//class{}
}//package{}
Ok thanks guys if you can see where my lagging problem is then can you hlep me out.