Skip to main content
November 13, 2008
Question

set the alpha of all MCs with specific name

  • November 13, 2008
  • 5 replies
  • 561 views
i want to loop throught all my movieclips and all the movieclips that have the name "bgTitle" i wand to set there alpha to 50%

(in my case the movieclips i am looking for are instances of the same mc that i have in the library.)
This topic has been closed for replies.

5 replies

November 13, 2008
thanks a lot Ned

for me it didnt work
the original version
I work with cs3,as2

i found out why
cause i have 2 mc that belongs to flash
and it caused the function to be endless
i added an if and it is working fine
if (property != "reserved" && property != "focusManager") {
you version that is lookink for a specific name
doent fine that two mc that cause the problem
Ned Murphy
Legend
November 13, 2008
I'm using CS3 as well. Yes, that function is not intended to find coding issues, just the mc that you said you wanted to find. Coding issues always lead to bad behavior.
November 13, 2008
its good for my example but the bgTitle is sometimes nested deep inside a mc and it can be also on the main timeline (_root)

i found this few lines of code that suppose to do the job, but they dont

function findClips (myClip, indentSpaces) {
// Use spaces to indent the child clips on each successive tier
var indent = " ";
for (var i = 0; i < indentSpaces; i++) {
indent += " ";
}
for (var property in myClip) {
// Check if the current property of myClip is a movie clip
if (typeof myClip[property] == "movieclip") {
trace(indent + myClip[property]._name);
// Check if this clip is parent to any other clips
findClips(myClip[property], indentSpaces + 4);
}
}
}
findClips (_root, 0); // Find all clip instances descended from main timeline

i took if from
http://oreilly.com/catalog/actscript/chapter/ch13.html
exaple 13-3
Ned Murphy
Legend
November 13, 2008
Your first sentence of your last reply made things much clearer.

That code you took from OReilly works fine for what it says it does, but you need to add some code to it to make it target the movieclips and change the alpha. Since I've never done it before, I spent some time figuring out how to make that happen (partly for you, but mostly for me). I've removed all of the tracing related code so that it doesn't get in the way of helping you to understand what is going on.

Ned Murphy
Legend
November 13, 2008
Well, if you want to loop thru all the movies, then you need to have their instances names stored in an array so that you can loop thru that array in targeting them.

var mc_Names = new Array("msgbox","basket",....);

for(z=0; z<mc_Names.length; z++){

this[mc_Names].bgTitle._alpha = 50;

}
November 13, 2008
they are instances of a mc but they are not on the same time line.
i have a mc named msgbox and inside it a mc named bgTitle, and i have also a mc that is named basket and inside it a mc named bgTitle,
there are 2 mcs that are instances of the same mc but have diffrent path
(actually i have much more than 2)
Ned Murphy
Legend
November 13, 2008
Okay, what problem are you having? In case... if you gave them all the same instance name, you can't change them all.