Let me help you Find that MovieClip
December 27th, 2006 . by polyGeekThe Find class (download here) is a utility built to help you find a specific MovieClip based on it’s properties.
To use it you send a reference to the MovieClip that contains a group of MovieClips and depending on the method you use it will return a reference to what it found. For instance, if you have a MovieClip named container that contains lots of MovieClips and you want to know which one of those MovieClips is the furthest to the right - largest _x value - then call Find.farRight(container). Since the method returns a reference to what it found you would want to use it as such:
var farRight:MovieClip = polyGeekcom.utils.Find.farRight(container);
There is also a method called mcIndex which will look to see if the instance name of the MovieClip you send it ends with a number. If so then the method returns that number. For instance, if you have a MovieClip named clip_15 you could write:
var indexNum:Number = polyGeekcom.utils.Find.mcIndex(clip_15);
Of course you would probably be using this in an instance when the MovieClip in question was created dynamically and you didn’t know what its index number was. This method works no matter what the MovieClips’ name is as long as it ends with a number. It could be clip_15, clip-15 or even clip15 and it will still return the number 15.
Here is a quick list of the remaining methods.
top: find and return the clip with the smallest _y value
bottom: find and return the clip with the largest _y value
absBottom: find and return the clip that extends the furthest to the bottom, takes into account the height of the clip and assumes that the clips registration point is 0,0.
farLeft: find and return the clip with the smallest _x value
farRight: find and return the clip with the largest _x value
absFarRight: find and return the clip that extends the furthest to the right, takes into account the width of the clip and assumes that the clips registration point is 0,0.
largest: find and return the largest movieclip by area
smallest: find and return the smallest movieclip
dimmest: find and return the movieclip with the lowest _alpha setting
brightest: find and return the movieclip with the highest _alpha setting
Note: If there are two or more MCs that meet the criteria being searched for then these methods will return just one of them. However, that returned MC
will have the propertie ‘tie’ dynamically appeneded to it with a value of true. So, if you need to check for ties then simply ask:
if( myFoundMovieClip.tie ) {
// there are multiple MCs that met your criteria so do something about it
}












Awesome, now how would I directly invoke dynamically created movieclips functions when they have dynamically assigned names?
I need to mix 31_mc’s ._x with 36_mc’s ._y
How would I reference it without linear design?
How could I say, when I click this, it is selected, and I want Selected_mc._x to mix with Selected_mc._y because each instance of this _mc is saying, onPress(){I’m the Selected.
@Dooley, I’m pretty sure you’re working in AS2. So here’s something that might work for you.
As you dynamically create each MC you tell it what it’s index number is and assign it a function to run when pressed
for(var i:Number = 0; i < something; ++i) {
var mc:MovieClip = myHolder.createEmptyMovieClip(”mc_” + i, i);
mc.myIndex = i;
mc.onPress = function {
doWhatever(this);
}
}
function doWhatever(clip:MovieClip):Void {
clip._alpha = 50;
myHolder[”clip” + ( clip.myIndex - 5 )]._alpha = 50; // fake reference
}
I just made up the stuff in the last line with the “fake reference” comment at the end. Presumably there would be some relationship between the clip that is pressed and the other clips that you want to manipulate.
If there is no relationship then it’s kinda hard to make this work dynamically.
I hope this helps. Or at least I hope it didn’t confuse you. :-)
Have a question thats sorta in the area.
duplicateMovieClip(DynaVid,
“Viewerwindow”+clipCnt, this.getNextHighestDepth()+1);
will generate movie clips Viewerwindow0,Viewerwindow1, etc.
How can I use this with something like
Viewerwindow.VideoObj
.attachVideo(tmpobj.netStream);?
I generate a new movie clip when the user goes to another movie so the number will change.
So you’re trying to find the last version of the duplicated MC, correct?
would something like this work:
currentVideoWin = duplicateMovieClip(DynaVid, “View…
currentVideoWin.attachVideo(…
Leave a Reply