Skip to main content
added 9 characters in body; edited title
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

Actionscript - Dropping Multiple Objects Usingmultiple objects using an Arrayarray in Actionscript?

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);
    }
}

Actionscript - Dropping Multiple Objects Using an Array?

I'm trying to get these fireBalls to drop more often, im not sure if im using Math.random correctly

also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one?

this 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);
    }
}

Dropping multiple objects using an array in Actionscript?

I'm trying to get these fireBalls to drop more often, I'm not sure if I'm using Math.random correctly.

Also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one?

This 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);
    }
}
Post Merged (destination) from gamedev.stackexchange.com/questions/26212/…
Source Link

Actionscript - Dropping Multiple Objects Using an Array?

I'm trying to get these fireBalls to drop more often, im not sure if im using Math.random correctly

also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one?

this 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);
    }
}