I'm trying to get these fireBallsfireBalls to drop more often, imI'm not sure if imI'm using Math.randomMath.random correctly.
alsoAlso, for some reason I'm getting a null referencenull reference because I think the fireBalls array waits for one to leave the stage before dropping another one?
thisThis is the relevant code:
var sun:Sun=new Sun
var fireBalls:Array=new Array()
var left:Boolean;
function onEnterFrame(event:Event){
if (left) {
sun.x = sun.x - 15;
}else{
sun.x = sun.x + 15;
}
if (fireBalls.length>0&&fireBalls[0].y>stage.stageHeight){ // Fireballs exit stage
removeChild(fireBalls[0]);
fireBalls.shift();
}
for (var j:int=0; j<fireBalls.length; j++){
fireBalls[j].y=fireBalls[j].y+15;
if (fireBalls[j].y>stage.stageHeight-fireBall.width/2){
}
}
if (Math.random()<.2){ // Fireballs shooting from Sun
var fireBall:FireBall=new FireBall;
fireBall.x=sun.x;
addChild(fireBall);
fireBalls.push(fireBall);
}
}