can anyone tell me why this code gives the desired results with 4 lines originating at a point, and all staying connected to a button, while the second pice of code makes a single line (possibly of four segments) to the top left corner of the stage, and stays there?? i think something is going wrong with the depths, and also maybe because the line variables can’t be declared by using var in front of it.
var line1:MovieClip = _root.createEmptyMovieClip("mc", 1);
var line2:MovieClip = _root.createEmptyMovieClip("mc", 2);
var line3:MovieClip = _root.createEmptyMovieClip("mc", 3);
var line4:MovieClip = _root.createEmptyMovieClip("mc", 4);
line1.onEnterFrame = line2.onEnterFrame = line3.onEnterFrame = line4.onEnterFrame = function () {
if(initialised) {
this.clear();
this.lineStyle(7.5, 0x999999, 100, false, "none", "square", "bevel");
this.moveTo(375, 350);
this.lineTo((_root['mainMenuButton' + (this.getDepth() - 1)]._x + 5), (_root['mainMenuButton' + (this.getDepth() - 1)]._y + 35));
}
}
code fragment 2:
for (i = 0; i < 4; i++) {
_root['line' + i] = this.createEmptyMovieClip("line", i + 1);
_root['line' + i].onEnterFrame = function () {
if(initialised) {
this.clear();
this.lineStyle(7.5, 0x999999, 100, false, "none", "square", "bevel");
this.moveTo(375, 350);
this.lineTo((_root['mainMenuButton' + i]._x + 5), (_root['mainMenuButton' + i]._y + 35));
}
}
}