Hello,
I am experimenting with arrays and have question. I have built this dot array
where a user can draw on the screen via the - Connenct the Dots - I have got
it to work but I need to place the dot in the the aTemp array in to the array
in the order the user clicks the dot. The way it works now is that the dot is
placed into the array but in numeric order. I hope I have explained this
correctly. LOL
Any help is greatly appreciated,
Rich
I have attached the code.
var scope = this;
var across:Number = 34;
// number of circles across
var down:Number = 16;
// number of circles down
var total:Number = across*down;
// total number of circles
var hsp:Number = 25;
// horizontal spacing
var vsp:Number = 25;
// vertical spacing
//var numberOfOscillations:Number = 12;
// how much of a complete curve to display at once
var bx:Number = 20;
// starting x position (Stage.width - hsp * across) / 2
var by:Number = 150;
// starting y position (Stage.height - vsp * down) / 2
var row:Number = 0;
var column:Number = 0;
var myArray = new Array();
var myArrayNum:String = new String();
for (i=0; i<total; i++) {
var noo:MovieClip = attachMovie("mov_dot", "dot"+i, i);
noo._alpha = 30;
noo.hitArea = noo.mc_HA;
noo._x = bx+column*hsp;
noo._y = by+row*vsp;
column++;
noo.position = 0;
myArray.push([noo._name, "off"]);
if (column == across) {
column = 0;
row++;
}
noo.onRelease = function() {
if (this.position == 0) {
scope.switchOn(this);
} else {
scope.switchOff(this);
}
};
}
function FindArrayNum(X) {
if (X._name.length == 4) {
var myArrayNum = X._name.substr(3, 1);
} else if (X._name.length == 5) {
var myArrayNum = X._name.substr(3, 2);
} else if (X._name.length == 6) {
var myArrayNum = X._name.substr(3, 3);
}
return myArrayNum;
}
onEnterFrame = function () {
clear();
var aTemp = new Array();
for (j=0; j<myArray.length; j++) {
if (myArray[j][1] == "on") {
aTemp.push(myArray[j][0]);
lineStyle(1, 0, 40);
moveTo(eval(aTemp[0])._x, eval(aTemp[0])._y);
for (k=1; k<aTemp.length; k++) {
lineTo(eval(aTemp[k])._x, eval(aTemp[k])._y);
}
}
}
};
function switchOn(X:MovieClip) {
myArray[FindArrayNum(X)][1] = "on";
X.gotoAndStop(2);
X.position = 1;
}
function switchOff(X:MovieClip) {
myArray[FindArrayNum(X)][1] = "off";
X.gotoAndStop(1);
X.position = 0;
}