After creating a container with 5 dynamically attached clips. I want to place the move the clips to coordinate from xArray and yArray the clips are not moving. What did I goof?
//VARIABLE TO STORE NUMBER OF CLIPS DESIRED
clipCount = 5;
xArray(25, 50, 75, 100, 125);
yArray(200, 250, 300, 350, 400);
newX = xArray[i-1];
// set coordinate X (destination)
newY = yArray[i-1];
// set coordinate Y (destination)
inertia = random(25)+8;
_root.createEmptyMovieClip("container_mc", 0);
function addClips() {
for (var i = 0; i<=clipCount; i++) {
container_mc.attachMovie("testClip", "theClip"+i, i);
container_mc["theClip"+i].onEnterFrame = function() {
move(this);
};
//trace("loaded");
}
}
addClips();
//FUNCTION TO MOVE THE CLIPS
function move(target) {
// calculate distance
target.distX = (target.newX-target._x);
// CHANGED
target.distY = (target.newY-target._y);
// CHANGED
// move
target._x += target.distX/target.inertia;
// CHANGED
target._y += target.distY/target.inertia;
// CHANGED
}