In the move function below, I’m attempting to have move return false, when it becomes true I want to delete this on enterframe event. In essence when the clips come to rest and the function is no longer needed delete the function call.
I missed something, but cannot figure out what.
//VARIABLE TO STORE NUMBER OF CLIPS DESIRED
clipCount = 6;
xArray = new Array(179.1, 249.1, 321.0, 179.1, 249.1, 321.0);
yArray = new Array(145.0, 144.0, 145.0, 206.0, 205.0, 204.0);
//Interface Assembly
function build() {
createEmptyMovieClip("container_mc", 2);
// attach container to stage
// attach buttons to container movie clip
//setting up clip variable.
for (i=1; i<=clipCount; i++) {
container_mc.attachMovie("testClip", "theClip"+i, i);
// define event handlers
container_mc["theClip"+i].onEnterFrame = function() {
//CALLING MOVE
move(this);
if (_root.move(this)) {
delete this.onEnterFrame;
}
//CALLING LABEL
label();
};
container_mc["theClip"+i].onRollOver = function() {
this._xscale = 110;
this._yscale = 110;
};
container_mc["theClip"+i].onRollOut = function() {
this._xscale = 100;
this._yscale = 100;
};
}
}
//FUNCTION CALL
build();
// MOVE BUTTONS TO NEW COORDINATES
function move(target) {
trace("moving");
//CALL THE POSITIOING
position();
// calculate distance
target.distX = (target.newX-target._x);
target.distY = (target.newY-target._y);
// move
target._x += target.distX/target.inertia;
target._y += target.distY/target.inertia;
return false;
}
function position() {
for (i=1; i<=clipCount; i++) {
container_mc["theClip"+i].newX = xArray[i-1];
// set coordinate X (destination)
container_mc["theClip"+i].newY = yArray[i-1];
// set coordinate Y (destination)
container_mc["theClip"+i].inertia = Math.floor(Math.random()*10)+10;
// set random inertia (number of steps before reaching destination)
}
}
function label() {
for (i=1; i<=clipCount; i++) {
container_mc["theClip"+i].number_txt.text = *;
}
}