views:

177

answers:

2

How can I use the counter value to multiply the frogs in the array? My counter goes from 0-100. I want to prove that I can increment the enemies using a counter.

EXPLAINED BETTER
I have 10 frogs in an array. I want to use a timer to add 10 more frogs on each iteration of the TimerEvent.TIMER firing.

alt text

//currentCount
var timer:Timer = new Timer(1000, 50);
timer.addEventListener(TimerEvent.TIMER, countdown);
timer.start();
function countdown(event:TimerEvent) {
//    myText.text = String(0 + timer.currentCount);
}



//Creates 10 enemies "I want enemies to multiply 0-100"
var enemyArray:Array = new Array();
for (var i:int = 0; i < 10; i++)
{
   var noname:FrogClass = new FrogClass();
   noname.x = i*10; //this will just assign some different x and y value depending on i.
   noname.y = i*11;
   enemyArray.push(noname); //put the enemy into the array
   addChild(noname); //puts it on the stage
}

alt text

SYMBOL PROPERTIES
NAME "noname"
CLASS "FrogClass"

WHY
I need specific examples using strings and arrays, because I'm stuck in a learning curve.
Stupid examples are more fun!

A: 

I want to prove that I can increment the enemies using a counter.

I am afraid I don't understand what this means.

Your for loop adds 10 FrogClass objects to an enemyArray Array. What is your desire from there? You want 100 frogs instead of 10? Just increase your for max value in your for loop to 100...

Be more specific about what you want.

Example:

I have 10 frogs in an array. I want to use a timer to add 10 more frogs on each iteration of the TimerEvent.TIMER firing. So after the timer.currentCount == 1 I would have 20 frogs.

OR

I have 10 frogs in an array. I want to use a timer to increase the speed of each frog in the array. So their speed starts at 1. After timer.currentCount == 1 their speed would be 1.1.

EDIT Based on better description

var enemyArray:Array = new Array();

var timer:Timer = new Timer(1000, 50);
timer.addEventListener(TimerEvent.TIMER, countdown);
timer.start();
function countdown(event:TimerEvent) {
    addFrogs(10);
}

function addFrogs($n:int):void {
    var noname:FrogClass;
    var offset:int = enemyArray.length;
    for (var i:int = 0; i < $n; i++)
    {
       noname = new FrogClass();
       noname.x = (i + offset) * 10;
       noname.y = (i + offset) * 11;
       enemyArray.push(noname); 
       addChild(noname);
    }
}

But, since you have your counter looping 50 times, this will add 500 frogs, not 100.

sberry2A
It proves it. Thanks!
VideoDnd
A: 

So how do I make the frog moves across the stage? I tried to change the noname.x value it didn't work. Please help!

V89