Hello, i am having a bit of an issue making a snow flake effect that doesn’t take up much cpu performance, this may be a bit of an oxymoron but i was hoping to see if anyone knew of a smart way of achiving this.
right now the animation only peaks at 18% on my dual core amd x2, but hits 100% hard on most computers i test on.
here is my current example --> http://www.uncommonsense.com/troy/babygirl/
here is my current fla -->
http://www.uncommonsense.com/troy/babygirl/holidayAdventure05.zip
here is my code for the snow flakes -->
//-------------------------------------------------------------------------------------------------
//SNOW CONTROLLER
//-------------------------------------------------------------------------------------------------
var j:Number = 0;
var i:Number = 0;
var t:Number = 0;
var rad:Number = 0;
var snowFlakeCount:Number = 0;
var snowFlakes:Array = new Array();
//CHANGEABLE VARS
var snowFlakeLimit:Number = 5;
//
this.onEnterFrame = snowController;
function snowController():Void {
//
for (j=0; j<snowFlakes.length; j++) {
var movieClip = snowFlakes[j];
movieClip._y += movieClip.i;
movieClip._rotation += movieClip.i;
movieClip.rad += (movieClip.k/180)*Math.PI;
movieClip._x -= Math.cos(movieClip.rad);
if (movieClip._y>Stage.height-50) {
movieClip.removeMovieClip();
snowFlakes.splice(j, 1);
snowFlakeCount--;
}
}
//
var randomNum = Math.round(Math.random()*25);
if (randomNum == 25) {
if (snowFlakeCount<snowFlakeLimit) {
i = 2+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
snowFlakeCount++;
t++;
if (t == 100) {
t = 1;
}
var randomNum = (Math.round(Math.random()*3))+1;
if (randomNum == 4) {
randomNum = (Math.round(Math.random()*3))+1;
}
var movieClip = eval("snowflake0"+randomNum+"_mov");
var snowflake = movieClip.attachMovie("snowFlake_lib", "snowFlake"+t, t);
snowflake._x = Math.random()*Stage.width;
snowflake._y = -100;
snowflake.i = i;
snowflake.k = k;
snowflake.rad = rad;
snowflake._xscale = snowflake._yscale=(Math.round(Math.random()*150))+51;
snowFlakes.push(snowflake);
}
}
}