Groups | Blog | Home
all groups > flash actionscript > september 2005 >

flash actionscript : Array Question?


Roks-1
9/9/2005 10:23:12 PM
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;
}
Alex Fex
9/9/2005 10:48:03 PM
I guess my question would be when storing this information in the temp array, what are you going to do with it?
Roks-1
9/9/2005 11:09:25 PM
Cut and paste this code in the first frame of a new fla in Flash.
Then create a symbol in the library named mov_dot and click the export for
actionscript toggle button.
Then test the movie
You can see what I have so far and what is in the aTemp Array.

Rich
Roks-1
9/11/2005 12:00:00 AM
Anyone want to try to give this a go Please!

Roks-1
9/13/2005 12:00:00 AM
Roks-1
9/13/2005 12:00:00 AM
I trying to create a matrix of dots where one can select a starting dot. Once
the uder selects the starting dot they select a second and it will draw a line
from the starting dot to the second dot. This continues as the user selects
additional dots in the matrix. I need to try to keep the order of the dots (ex.
0,1,2,3 etc.) as they are selected and then delete them from the order when
they are deselected. I am almost there just need a little help.

Thanks,
Rich
fasilak NO[at]SPAM gmail.com
9/13/2005 12:27:02 PM
Can u be more clear with what you are trying to do with the dots.



AddThis Social Bookmark Button