I am generating childs of the same movieclip over and over again after some specific time difference. At any instance, i require all the movieclips on stage to pause at once and play again after another interval. Any suggestion on how may I do that? I am using flash professional CS5.5 and actionscript 3.0.
2 Answers
0
votes
Each time you generate a new child, push it to an array:
var myArray:Array = new Array();
function makeChildren() {
var newChild:MovieClip = new originalMC();
myArray.push(newChild);
addChild(newChild);
}
Then you'll have access to all the generated movieclips to do with as you please. When you need to pause or play them all, just run a for each loop:
for each(var myVar in myArray) {
myVar.pause(); // or myVar.play();
}
Sound like what you're looking for?
0
votes
I you are unable to keep all object in the same array, you could scan the display list recursively and check each single object:
function lookRecursively( target : DisplayObjectContainer ) : void
{
for ( var i:int = 0, l:int = target.numChildren; i < l; i++ ) {
var child:DisplayObject = target.getChildAt(i);
if ( child is DisplayObjectContainer ) {
if ( DisplayObjectContainer(child).numChildren > 0 ) {
if ( child is SOME_OBJECT_CLASS_HERE ) {
// do what you gotta do here...
} else {
lookRecursively( DisplayObjectContainer ( child ) );
}
}
}
}
}