Be a Supporter!

quick array question as3

  • 185 Views
  • 1 Reply
New Topic Respond to this Topic
newave
newave
  • Member since: Aug. 9, 2010
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
quick array question as3 2010-11-16 21:20:59 Reply

Hey guys, I have an array that i am using to store my mc class. How do i limit my array so that it only gives me a certain amount of mc's at a time like say 5 waves of 10 mc's? Looked on the web for a tutorial and can't find what I need:

var mc:Mc;

var flashtimer = new Timer(2500);
flashtimer.start();
flashtimer.addEventListener(TimerEvent.T IMER, createNewmc;

function createNewmc (e:TimerEvent) : void
{

var enemyArray:Array = new Array();
for (var i:int = 0; i <3; i++)
{
var mc:Mc = new Mc();
mc.x =Math.random() * 480;
mc.y = 180;
mc.scaleX = .2;
mc.scaleY = .2;
mc.addEventListener (Event.ENTER_FRAME, spidermove);
mc.addEventListener (MouseEvent.CLICK, killspider1);
mc.addEventListener (Event.ENTER_FRAME, sp1onTime);
enemyArray.push(mc); //put the enemy into the array
addChild(mc);

Thanx!!!!!!!!!!!!!!!!!!!

quick array question as3

Tygerman
Tygerman
  • Member since: Aug. 16, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to quick array question as3 2010-11-17 15:46:23 Reply

You basically have what you need, just put the for loop inside an if statement that says

if(flashTimer reaches a certain time){
your for loop with i<10 instead of i<3
}

and if you only want 5 waves put the

flashTimer.start()

into a for loop that loops 5 times


BBS Signature