hello everybody,
my ridiculous problem :
this an AS code which work :
ecart_cat = 90;
destx_cat1 = 150.1;
destx_cat2 = destx_cat1+ecart_cat;
destx_cat3 = destx_cat1+2ecart_cat;
destx_cat4 = destx_cat1+3ecart_cat;
destx_cat5 = destx_cat1+4*ecart_cat;
cat1.onEnterFrame = function() {
distpx_cat1 = destx_cat1-cat1._x;
cat1._x += distpx_cat1*(0.1);
if (Math.abs(distpx)<1) {
delete cat1.onEnterFrame;
}
};
cat2.onEnterFrame = function() {
distpx_cat2 = destx_cat2-cat2._x;
cat2._x += distpx_cat2*(0.1);
if (Math.abs(distpx)<1) {
delete cat2.onEnterFrame;
}
};
cat3.onEnterFrame = function() {
distpx_cat3 = destx_cat3-cat3._x;
cat3._x += distpx_cat3*(0.1);
if (Math.abs(distpx)<1) {
delete cat3.onEnterFrame;
}
};
cat4.onEnterFrame = function() {
distpx_cat4 = destx_cat4-cat4._x;
cat4._x += distpx_cat4*(0.1);
if (Math.abs(distpx)<1) {
delete cat4.onEnterFrame;
}
};
cat5.onEnterFrame = function() {
distpx_cat5 = destx_cat5-cat5._x;
cat5._x += distpx_cat5*(0.1);
if (Math.abs(distpx)<1) {
delete cat5.onEnterFrame;
}
};
I just want to reduce it like this :
n = 6;
for (i=1; i<n; i++) {
[“cat”+i].onEnterFrame = function() {
distpx_[“cat”+i] = destx_[“cat”+i]-[“cat”+i]._x;
[“cat”+i].x += distpx[“cat”+i]*(0.1);
if (Math.abs(distpx)<1) {
delete [“cat”+i].onEnterFrame;
}
};
}
but it doesn’t work
please, help me.