Skip to main content
added 466 characters in body
Source Link

edit:I'm slightly unclear on the question but I think this is the answer?

I would ditch the timer altogether and just use an enter-frame event listener.

var playerArr:Array=[];
var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

   //assuming your at 30fps
   if (t%900t%900==1){
   spawnUnits(3)
  }
}


//If you were spawning Characters for the first time
function spawnUnits(numUnits:int){
    for(i=0;i<=numUnits;i++){
    newSpawn:MovieClip=new *CLASSNAME*
    newSpawn.x=Math.Random()*400;
    newSpawn.y=200;
    playerArr.push(newSpawn);
    addChild(newSpawn);
    }
}

//If you were grabbing previously spawned Characters and moving them you would 
//Call this function instead of spawnUnits

function characterMover(){
    var moveChar:Object=playerArr[(Math.Random()*playerArr.length)-1];
    moveChar.x=Math.Random()*400;
    moveChar.y=200;
    //then if they weren't already on the display list you could add them here
    
}

edit:I'm slightly unclear on the question but I think this is the answer?

I would ditch the timer altogether and just use an enter-frame event listener.

var playerArr:Array=[];
var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

   //assuming your at 30fps
   if (t%900){
   spawnUnits(3)
  }
}



function spawnUnits(numUnits:int){
    for(i=0;i<=numUnits;i++){
    newSpawn:MovieClip=new *CLASSNAME*
    newSpawn.x=Math.Random()*400;
    newSpawn.y=200;
    playerArr.push(newSpawn);
    addChild(newSpawn);
    }
}

edit:I'm slightly unclear on the question but I think this is the answer?

I would ditch the timer altogether and just use an enter-frame event listener.

var playerArr:Array=[];
var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

   //assuming your at 30fps
   if (t%900==1){
   spawnUnits(3)
  }
}


//If you were spawning Characters for the first time
function spawnUnits(numUnits:int){
    for(i=0;i<=numUnits;i++){
    newSpawn:MovieClip=new *CLASSNAME*
    newSpawn.x=Math.Random()*400;
    newSpawn.y=200;
    playerArr.push(newSpawn);
    addChild(newSpawn);
    }
}

//If you were grabbing previously spawned Characters and moving them you would 
//Call this function instead of spawnUnits

function characterMover(){
    var moveChar:Object=playerArr[(Math.Random()*playerArr.length)-1];
    moveChar.x=Math.Random()*400;
    moveChar.y=200;
    //then if they weren't already on the display list you could add them here
    
}
Post Undeleted by Zee Bashew
added 322 characters in body
Source Link

edit:I'm slightly unclear on the question but I think this is the answer?

I would ditch the timer altogether and just use an enter-frame event listener.

var playerArr:Array=[];
var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

   //assuming your at 30fps
   if (t%900){
   spawnUnits(3)
  }
}



function spawnUnits(numUnits:int){
    for(i=0;i<=numUnits;i++){
    newSpawn:MovieClip=new *CLASSNAME*
    newSpawn.x=Math.Random()*400;
    newSpawn.y=200;
    playerArr.push(newSpawn);
    addChild(newSpawn);
    }
}

I would ditch the timer altogether and just use an enter-frame event listener.

var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

//assuming your at 30fps
if (t%900){
spawnUnits(3)}

edit:I'm slightly unclear on the question but I think this is the answer?

I would ditch the timer altogether and just use an enter-frame event listener.

var playerArr:Array=[];
var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

   //assuming your at 30fps
   if (t%900){
   spawnUnits(3)
  }
}



function spawnUnits(numUnits:int){
    for(i=0;i<=numUnits;i++){
    newSpawn:MovieClip=new *CLASSNAME*
    newSpawn.x=Math.Random()*400;
    newSpawn.y=200;
    playerArr.push(newSpawn);
    addChild(newSpawn);
    }
}
Post Deleted by Zee Bashew
Source Link

I would ditch the timer altogether and just use an enter-frame event listener.

var t:int=0;
public function Main(){ 
addEventListener(Event.ENTER_FRAME, tick)
}


function tick(){

t++;

//assuming your at 30fps
if (t%900){
spawnUnits(3)}