Forums → Programming Forum → AS3: Count number of children movieclips?
- 1 Reply
I have buttons that create specific movie clips such as a library object named "Clip_1":
var b:MovieClip = new Clip_1();
b.name = "Clip_1";
So I can add many Clip_1's, Clip_2's and so on, by their corresponding buttons.
I cannot figure out how to count the number of them that exist on the stage, however and I've looked all over the nets.
I would like the number of Clip_1 instances to display in a text field.
For example: If there are 20 on the stage, the text field should display 20, if one is removed, it should display 19.
I would be grateful for any helpful hints, thank you.
I am away from my home at the moment so I didn't test, but I think this should work.
//name all children on MovieClip as i in your case MC is b
alternatively you can try
//create an array
private var testArray:Array;
//add this after you create movieclip
testArray.push( MC );
for each (var MC in testArray)
trace("movieClip on Screen"
You must be logged in to post a reply!
We strive to deliver the best gaming experiences... on the internet and on your mobile phone. Play thousands of free online games for kids, get access to free mmorpg games, online rpg games, fun online flash games, and more.
We offer free flash games in many different genres: online shooting games, online puzzle games, online war games, free online car games, free online hidden object games and dozens more.
This is the best place on the web to play online games for free... play on Armor Games! No matter what game style you prefer, we've got it here.
Gaming websites, passionate bloggers, and quirky streamers are welcome to share or review our games. If you need game keys, art, trailers, screenshots or more check out our press kit website.
Game developer? Visit developers.armorgames.com to request AG developer status, find documentation on our APIs, and get access to our development environment. Let's make sweet, sweet games together.
Looking for a publishing partner that can help your app rocket to success? Contact the mobile team to learn more about how we can help!