If you duplicate a movie clip with say the name “ball” you end up with ball1, ball2, ball3, etc., on level0.
If I want to call out an instance in my main movie that is duplicated how can I achieve this?
Anyone?
If you duplicate a movie clip with say the name “ball” you end up with ball1, ball2, ball3, etc., on level0.
If I want to call out an instance in my main movie that is duplicated how can I achieve this?
Anyone?
um… dunno if that’s what you mean but try it:
created mc named ball1, ball2, ball3,…,ballN
for (j=1; j!=N;j++) _root["ball"+j].onEnterFrame = function() {
this._y += 5;
}
dunno if it even works…
yeah, that code should work. basically, you’d access an instance like you’d access any other, by its name. if you created the instances dynamically, it’s always possible to access each instance you created.
for example:
onClipEvent(load) {
for (i = 0; i < 10; ++i) {
this.duplicateMovieClip("ball"+i, i);
}
}
onClipEvent(enterFrame) {
for (i = 0; i < 10; ++i) {
mc = _root["ball"+i];
with(mc) {
++_x;
--_y;
}
}
}
notice that i used _root[“ball”+i] up there. when you dynamically access an instance you can’t simply say:
“ball”+i._x = 250;
flash will give you an error or two. rather you’d direct where the actual instance is, which in the example, is in _root. you can also use _parent or another movieclip:
main_ball[“ball”+i];
let me know if you’re still confused.
Well I may have not made my problem clear. I have the duplicate movie thing down. My problem is that there is an instance on the button I am duplicating that is called out to change its color. However, when it is duplicated and you get ball1, ball2 and ball3 etc., I cannot reach that instance anymore.
here is my duplicate code and I also attached the test movie. The colored button is what I am trying to reference the instance in the duplicated buttons.
on (press) {
num = 10;
xstart = -25;
n = 1;
while (n <= num) {
duplicateMovieClip(“testy”, “ball” add n, n);
setProperty(“ball” add n, _x, xstart + n*35);
n = n + 1;
}
setProperty(“testy”, _visible, 0);
}
hm…i looked at your code and i don’t know if this will help, but it looks like you duplicate those buttons on the same depth. you can only have one created instance per layer or the new one replaces the one currently in that layer.
:: Copyright KIRUPA 2024 //--