Skip to main content
Known Participant
January 29, 2009
Question

arrays and addchild

  • January 29, 2009
  • 1 reply
  • 295 views
Hi,

I have a load of movieclips that have the custom base class called 'Card'. I want to make an array of their names and add them to my stage

var list:Array = new Array("comedyFront", "casinoFront");

for (var j:int = 0; j < list.length; j++)
{
var myMovieClip:Card = new Card(list[0]);
this.addChild(myMovieClip);
}

any ides how I do this? The error is

1137: Incorrect number of arguments. Expected no more than 0.
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
January 29, 2009
var list:Array = new Array("comedyFront", "casinoFront");

for (var j:int = 0; j < list.length; j++)
{
var classRef:Class = getDefinitionByName(list) as Class;
var mc:* = new classRef();
this.addChild(mc);
}