Question
Finding Movie Clip Name
Hello,
I have 108 movie clips on my stage which make up a grid. The grid was generated dynamically using movieclips a while loop.
Each movie clip has been given its own unique instance name.
Now i want all the movie clips to have the same functions. I did not want to write lines and lines of:
mc1.onRelease = function () {
actions();
}
mc2.onRelease = function () {
actions();
}
mc3.onRelease = function () {
actions();
}
mc4.onRelease = function () {
actions();
}
mc5.onRelease = function () {
actions();
}
etc..etc...etc....etc.....etc
as this would make my code very long, ugly and a little difficult and time consuming to debug.
INSTEAD....
I want to know if there is a way of being able to click on any movie clip and its name will be recalled, without having to know the name of the movie clip, by using a MouseUp action or equivalent and be stored in a variable.
For example.
If i click on one of my movie clips, its name is then stored into a variable called (myButton). That variable will then act as the name of the function:
myButton.onRelease = function() {
actions();
}
the myButton variable will then tell the onRelease function which button to use its functions on. This would mean that i could use 3 lines of code instead of 300+ lines of code.
Firstly, does anyone know if this can be done? And if it can it would be greatly appreciated if you could show me how to do this.
If you are wanting to have a look at my script for a guide as to what im doing, please let me know
Thank You
I have 108 movie clips on my stage which make up a grid. The grid was generated dynamically using movieclips a while loop.
Each movie clip has been given its own unique instance name.
Now i want all the movie clips to have the same functions. I did not want to write lines and lines of:
mc1.onRelease = function () {
actions();
}
mc2.onRelease = function () {
actions();
}
mc3.onRelease = function () {
actions();
}
mc4.onRelease = function () {
actions();
}
mc5.onRelease = function () {
actions();
}
etc..etc...etc....etc.....etc
as this would make my code very long, ugly and a little difficult and time consuming to debug.
INSTEAD....
I want to know if there is a way of being able to click on any movie clip and its name will be recalled, without having to know the name of the movie clip, by using a MouseUp action or equivalent and be stored in a variable.
For example.
If i click on one of my movie clips, its name is then stored into a variable called (myButton). That variable will then act as the name of the function:
myButton.onRelease = function() {
actions();
}
the myButton variable will then tell the onRelease function which button to use its functions on. This would mean that i could use 3 lines of code instead of 300+ lines of code.
Firstly, does anyone know if this can be done? And if it can it would be greatly appreciated if you could show me how to do this.
If you are wanting to have a look at my script for a guide as to what im doing, please let me know
Thank You
