PDA

View Full Version : Prototyping...


Ledge
05-24-2005, 03:43 PM
Do you know if there is a way to write a prototype that will effect all of the children under it?

Take for example if I created this prototype for MC to count all of the frames. But I want it count all of the frames in every MC below it.

Is that possible?

I am trying to build a Timer that will take into account all of the sub movieclips.

eclection
05-24-2005, 04:25 PM
i don't believe so in and of itself, not how you are thinking.

but you could have an array of a set of movieclips then a for loop to add up their _currentframe

sleekdigital
05-24-2005, 05:17 PM
You would not necesarily need an array .. you can use a "for ... in" loop and check each obejct to make sure it is a movieclip.

eclection
05-24-2005, 05:19 PM
true, i never think about the for...in... i ignore it like in favor of more precise control over what exactly is being modified. but sleekd is right

Ledge
05-25-2005, 01:12 AM
Actually what ended up working was this:


function countMyFrames(mc){
var sum = mc._totalframes;
for (childEnum in mc) {
var child = mc[childEnum];
sum += countMyFrames(child);
}
return sum
}


The thing that doesn't work so well is the fact that if the playhead hadn't reached a MC yet when this script was run, it won't include the frames in that MC. The script would then have to be run again to include that MC in the count.

This is a way less than perfect solution though. I need to figure up how many frames are in a swf before it plays, including all the children mc's that are in that SWF. All this with not knowing what MC's are in the swf.

sleekdigital
05-25-2005, 02:03 AM
Well, um, yeah, thats a for.. in loop just as I suggested. As far as your next problem .. why don't you just have all of your MCs on the stage? Just have them stopped and out of view (use negative x, y values) until they are needed.