so i have this program that duplicates Mr. T himself (‘tman0’, located in the ‘f1’ clip) on button press (button is called ‘plus’ located in the ‘control’ MC), and assigns each duplicate a number drawn from the array (cnums) and inputs that number in the output text box (output2.text). i am borrowing the algorithm explained in this kirupa tutorial. anyways, Mr. T duplicates, but in the same exact position. i’m pretty sure the problem lies in my button statement, but i’ve included it all here anyway. please check this out and if you see anything and can offer some advice, i’d appreciate it. all of this code is located in the _root movie and is in the first frame.
thanks!
stop();
amount = 30; //the maximum amount of tman instances allowed
cnums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; //numbers to be assigned to the output.text box for each duplicate tman clip
f1.tman0.onLoad = function () {
width = 800;
height = 600;
speed = Math.round(Math.random()*2)+1;
x1 = Math.random()*width;
y1 = Math.random()*height;
this._x = x1;
this._y = y1;
x_new = Math.random()*width;
y_new = Math.random()*height;
}
f1.tman0.onEnterFrame = function () {
if (x_new > this._x) {
sign_x = 1;
}
else {
sign_x = -1;
}
dx = Math.abs(x_new - this._x);
if ((dx > speed) || (dx < -speed)) {
this._x += sign_x*speed;
}
else {
x_new = Math.random()*width;
}
if (y_new > this._y) {
sign_y = 1;
}
else {
sign_y = -1;
}
dy = Math.abs(y_new - this._y);
if ((dy > speed) || (dy < -speed)) {
this._y += sign_y*speed;
}
else {
y_new = Math.random()*height;
}
}
f1.control.onRelease = function() {
if (amount > 0) {
i = i++;
cname = "tman" + i; //duplicated clip instance
duplicateMovieClip (f1.tman0, cname, i); //duplicates the movie
amount = amount - 1; //decrements the amount value until it reaches zero, then executes the else statement
this[cname].output2.text = cnums*; //places the corresponding array i value into the output2.text for each duplicated clip
}
else {
this[cname].output1.text = "too many mister T's. reload the movie." //executes when the amount is lesser than zero
}
}