all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

Get Instance


Get Instance silverfh
1/9/2005 10:33:18 PM
flash actionscript: hi friends, I got a little strange situation here.. is there any way thay I
canget all the instance names of the movies that are placed inside a movie..
lets say I have a Movie (A) .. an in it there are 3 movies (one) (two)
(three).. now the situation is that, that I dont know the instance names of
those 3 movies.. or may be I dont know at all that how much movies are on there
(in movie 'A').. so is there anyway that I can get those instance names ?
Thanks friends.. :confused;
Re: Get Instance kglad
1/10/2005 2:04:30 AM
for(mc in mcA){
trace(mcA[mc]);
Re: Get Instance NSurveyor
1/10/2005 2:13:41 AM
You'd probably want to do:

for(mc in mcA){
if(typeof(mcA[mc])=='movieclip'){
trace(mcA[mc]);
}
}
Re: Get Instance Jeckyl
1/10/2005 2:26:06 PM
Even then you can get into trouble if you have some variables that happen to
have references to other clips in them .. they'll get traced too.

To make it a little safer, you can include this improved code, which uses a
local var (if the code appears in a function) and also checks that the clip
you find is actually a child of the mcA clip ...

for (var mc in mcA) {
if (typeof mcA[mc] == 'movieclip') {
if (mcA[mc]._parent == mcA) {
trace(mcA[mc]);
}
}
}

Its actually quite hard to guarantee you'll ONLY get child movie clips, and
only get each one once only. Unless you know what all the variables hold.
--
All the best,
Jeckyl

AddThis Social Bookmark Button