PDA

View Full Version : duplicate mc


bahrami
02-19-2007, 12:28 PM
Hello Everybody!
I'm having problems with duplicate MC

for (x=0; x<10; x++) {
duplicateMovieClip ("_root.boll", "dupMC"+x, x);
_root["dupMC"+x]._x = random (100);
_root["dupMC"+x]._y = random (100);



}



my_btn.onRelease = function () {
_root["dupMC"+x].gotoAndPlay(2)
};


I need that button to do something with my dplicated Mc.
I have noticed that I cant modify my duplicated mc outside the DuplicateMc funktion. Is there a way cross that.

mooska
02-19-2007, 12:39 PM
for(var i=0; i<10; i++){
this.boll.duplicateMovieClip("dupMc"+i, i);
var mc = this["dupMc"+i];
mc._x =100;
mc._y = 100
}
btn_mc.onPress = function(){
this._parent.dupaMc0.gotoAndPlay(2);
}

bahrami
02-19-2007, 05:57 PM
allright thanx,, but I have a nother question now, why do you put "var" infront your variables.

mooska
02-19-2007, 06:02 PM
that makes them local, such variable will be deleted after function has ended.

bahrami
02-19-2007, 06:45 PM
ok!
Now I have tested your code. But I cant still achive what I'm looking for. I need to accecc my duplicated mcs properties outside the duplicate mc. Se the example below.

for(var i=0; i<10; i++){
_root.boll.duplicateMovieClip("dupMc"+i, i);
var copy = this["dupMc"+i];
}
copy._y = random (100)
copy._x = random (300);

What I´m trying to do is to set all my duplicates copies on diffrent positions. It works fine when I put the code inside the duplicate funktion like this:

for(var i=0; i<10; i++){
_root.boll.duplicateMovieClip("dupMc"+i, i);
var copy = this["dupMc"+i];
copy._y = random (100)
copy._x = random (300);
}

But I need to achive the same effect but with the properties outside the funktion like the first example, and that doesnt work for me right now. I need to know how I cant do that.