Skip to main content
Inspiring
July 11, 2011
Answered

Count how many movieclip in stage

  • July 11, 2011
  • 1 reply
  • 989 views

Dear all,

I have these particular movieclips that I would want to count. They are all an instance of mc_invis_table and they each have an instance name : mc_invis_table_1, mc_invis_table_2, mc_invis_table_3 ..... and so on..... till mc_invis_table_18.

How do I count the number of instance of mc_invis_table on stage?

-Zainuu

This topic has been closed for replies.
Correct answer

try :

var sum:uint=0;

for(var i:uint;i<numChildren;i++)
{
var nameofMc:String=getChildAt(i).name;
if(nameofMc.slice(0,15)=="mc_invis_table_")
{
  sum++;
}
}

trace(sum);

1 reply

Correct answer
July 11, 2011

try :

var sum:uint=0;

for(var i:uint;i<numChildren;i++)
{
var nameofMc:String=getChildAt(i).name;
if(nameofMc.slice(0,15)=="mc_invis_table_")
{
  sum++;
}
}

trace(sum);