Hey all,
So i have developed and am refining some “mouse follow” code. The code works great. What doesn’t work is my ability to add a blur effect. The idea is that the faster the mc is moving, the more blurry it is made. Sounds simple… heh heh
I have started by simply applying a static blur value in the code… like such:
function mouseFollow(centerx:Object, centery:Object, inertia:Number, k:Number) {
//trace ("we are calling the mouse follow function");
Dx = -this_mc._x+centerx;
Dy = -this_mc._y+centery;
Px = Px*inertia+Dx*k;
Py = Py*inertia+Dy*k;
this_mc._x += Px;
this_mc._y += Py;
trace(Math.round(Dx/10));
//
// blur mechanism
//
var blurFilter = new flash.filters.BlurFilter();
var filterArray:Array = this_mc.filters;
filterArray.push(blurFilter)
//
filterArray[0].blurX = 2;
this_mc.filters = filterArray;
}
the mc is blurred just fine. But my CPU is PISSED at me. Suggestions for how to best optimize this code? perhaps there is a less brute force way of doing this? Or is the “filter” aspect simply a CPU pig?