Drag drop issuse

stacking boxes issuse,… I have a grid on the stage that when you drag the grey boxes onto the screen it drops them to the bottom of the column, I got them stacking fine… but trying to figure out a little bug… if I drag 4 boxes into the same column and then drag the bottom box out to another column… the 3 boxes left are still in their orginal place… I want them to drop down one giving the illusion that the box thats was dragged out from under the other boxes was holding them out… not sure on the most effective way to code this… any ideas…? since I probally made no sense after a 6 pack and writing this heres the code… just paste it in a empty flash file and publish…if you want to see what I’m trying to say… :slight_smile:


///////////////////////////////////////////////////////////////////////////////////
// MC Prototypes.
///////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.drawBox = function(x, y, w, h, lineWidth, lineColor, bgColor, whoami) {
	this.beginFill(bgColor, 100);
	this.lineStyle(lineWidth, lineColor, 100);
	this.moveTo(x, y);
	this.lineTo(x+w, y);
	this.lineTo(x+w, y+h);
	this.lineTo(x, y+h);
	this.endFill();

};
///////////////////////////////////////////////////////////////////////////////////
// fraw outter frame and the boxes to drag
///////////////////////////////////////////////////////////////////////////////////
var locX = 0;
var locY = 0;
this.createEmptyMovieClip("mc_frame", 2);
this.mc_frame.drawBox(this.locX+0, this.locY+0, 800, 600, 1, 0x000000, 0x000000);
this.mc_frame.drawBox(this.locX+2, this.locY+2, 796, 596, 1, 0xFFFFFF, 0xFFFFFF);
for (k=0; k<10; k++) {
	this.createEmptyMovieClip("mc_box"+k, 50+k);
	this["mc_box"+k].drawBox(this.locX+0, this.locY+0, 40, 40, 1, 0x000000, 0x000000);
	this["mc_box"+k].drawBox(this.locX+2, this.locY+2, 36, 36, 1, 0x979797, 0x979797);
	this["mc_box"+k]._x = 10+(50*k);
	this["mc_box"+k]._y = 10;
	this["mc_box"+k].createTextField("stat", 2, 10, 10, 50, 40);
	this["mc_box"+k].stat.selectable = 0
	this["mc_box"+k].stat.text = k
	this["mc_box"+k].xst = this["mc_box"+k]._x;
	this["mc_box"+k].yst = this["mc_box"+k]._y;
	// buuton to drag
	this["mc_box"+k].onPress = function() {
		startDrag(this);
	};
	this["mc_box"+k].onRelease = function() {
		dropBox(this);
	};
}
///////////////////////////////////////////////////////////////////////////////////
// draw a grid on the stage 
///////////////////////////////////////////////////////////////////////////////////
this.createEmptyMovieClip("mc_grid", 3);
this.mc_grid.drawBox(this.locX+0, this.locY+0, 780, 490, 1, 0x000000, 0x000000);
this.mc_grid.drawBox(this.locX+2, this.locY+2, 776, 486, 1, 0xFFFFFF, 0xFFFFFF);
this.mc_grid._x = 10;
this.mc_grid._y = 100;
this.mc_grid.createEmptyMovieClip("gridholder", 2);
this.mc_grid.gridholder._x = 8;
this.mc_grid.gridholder._y = 10;
var rows = 10;
var cols = 19;
for (y=0; y<rows; y++) {
	for (z=0; z<cols; z++) {
		this.mc_grid.gridholder.createEmptyMovieClip("grid_"+y+"_"+z, (y+91)*(z+199));
		this.mc_grid.gridholder["grid_"+y+"_"+z].drawBox(2, 2, 40, 40, 1, 0x000000, 0x000000);
		this.mc_grid.gridholder["grid_"+y+"_"+z].drawBox(3, 3, 38, 38, 1, 0xFFFFFF, 0xFFFFFF);
		this.mc_grid.gridholder["grid_"+y+"_"+z]._x = 40*z;
		this.mc_grid.gridholder["grid_"+y+"_"+z]._y = 40*y;
	}
}
///////////////////////////////////////////////////////////////////////////////////
// draw _droparea  for the column's
///////////////////////////////////////////////////////////////////////////////////
for (x=0; x<cols; x++) {
	this.createEmptyMovieClip("mc_drop_"+x, 4+x);
	this["mc_drop_"+x].drawBox(this.locX+0, this.locY+0, 40, 400, 1, 0x000000, 0x000000);
	this["mc_drop_"+x].drawBox(this.locX+2, this.locY+2, 36, 396, 1, 0xFFFFFF, 0xFFFFFF);
	this["mc_drop_"+x]._x = (x*40)+20;
	this["mc_drop_"+x]._y = 111;
	this["mc_drop_"+x]._alpha = 0;
}
///////////////////////////////////////////////////////////////////////////////////
// graph data area // keep track of how many boxes in a column
///////////////////////////////////////////////////////////////////////////////////
col_A_count = 0;
col_B_count = 0;
col_C_count = 0;
col_D_count = 0;
col_E_count = 0;
col_F_count = 0;
col_G_count = 0;
col_H_count = 0;
col_I_count = 0;
col_J_count = 0;
col_K_count = 0;
col_L_count = 0;
col_M_count = 0;
col_N_count = 0;
col_O_count = 0;
col_P_count = 0;
col_Q_count = 0;
col_R_count = 0;
col_S_count = 0;

///////////////////////////////////////////////////////////////////////////////////
// func to place boxes on the grid and stack them 
///////////////////////////////////////////////////////////////////////////////////
function dropBox(who) {
	if (eval(who._droptarget) == _level0.mc_drop_0) {
		col_A_count++;
		who._x = 20;
		who._y = 512-(col_A_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_1) {
		col_B_count++;
		who._x = 60;
		who._y = 512-(col_B_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_2) {
		col_C_count++;
		who._x = 100;
		who._y = 512-(col_C_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_3) {
		col_D_count++;
		who._x = 140;
		who._y = 512-(col_D_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_4) {
		col_E_count++;
		who._x = 180;
		who._y = 512-(col_E_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_5) {
		col_F_count++;
		who._x = 220;
		who._y = 512-(col_F_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_6) {
		col_G_count++;
		who._x = 260;
		who._y = 512-(col_G_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_7) {
		col_H_count++;
		who._x = 300;
		who._y = 512-(col_H_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_8) {
		col_I_count++;
		who._x = 340;
		who._y = 512-(col_I_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_9) {
		col_J_count++;
		who._x = 380;
		who._y = 512-(col_J_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_10) {
		col_K_count++;
		who._x = 420;
		who._y = 512-(col_K_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_11) {
		col_L_count++;
		who._x = 460;
		who._y = 512-(col_L_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_12) {
		col_M_count++;
		who._x = 500;
		who._y = 512-(col_M_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_13) {
		col_N_count++;
		who._x = 540;
		who._y = 512-(col_N_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_14) {
		col_O_count++;
		who._x = 580;
		who._y = 512-(col_O_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_15) {
		col_P_count++;
		who._x = 620;
		who._y = 512-(col_P_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_16) {
		col_Q_count++;
		who._x = 660;
		who._y = 512-(col_Q_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_17) {
		col_R_count++;
		who._x = 700;
		who._y = 512-(col_R_count*40);
	} else if (eval(who._droptarget) == _level0.mc_drop_18) {
		col_S_count++;
		who._x = 740;
		who._y = 512-(col_S_count*40);
	} else {
		who._x = who.xst;
		who._y = who.yst;
	}
	this.stopDrag();
}
///////////////////////////////////////////////////////////////////////////////////
// end long func to place grey box
///////////////////////////////////////////////////////////////////////////////////

stop();

any ideas or suggestions whould be great… time to get another 6 pack… :cool: