Hi,
I am updating these files, and I ran across a problem with the drag and drops allowing for the drag objects to be able to drop on the same target, I have tried a few different things to fix it, but I seem to be missing something…
Files:
http://www.jkromans.com/Work/dd.swf
http://www.jkromans.com/Work/dd.fla
DD Code:
var maxDepth:Number = 200;
init = function(){
for(i=1; i<=numQuestions; i++){
//occupied* = false;
//trace("these are "+occupied*);
drag_mc = this[“drag”+i];
target_mc = this[“drop”+i];
trace("target_mc initial values = "+target_mc);
drag_mc.num = i;
drag_mc.whereDropped = 0;
drag_mc.onPress = function(){
this.swapDepths(maxDepth+i);
this.startDrag();
this.initX = this._x;
///target_mc = undefined;
//checkTarget(target_mc);
}
drag_mc.onRelease = function(){
this.swapDepths(maxDepth);
this.stopDrag();
var dt:String = this._droptarget
var dropNum = Number(substring(dt,4,1));
drag_mc.whereDropped = dropNum;
//trace("dt = " + this.whereDropped)
//trace("getProperty(this._droptarget, _x) = " + getProperty(this._droptarget, _x))
trace("this is the target = "+target_mc);
checkTargets();
if (dt.indexOf("dz",dt.lastIndexOf(".")) > 0)
{
target_mc = this._droptarget;
trace("this is where this is being droped:"+this._droptarget+" also the target mc is equal to "+target_mc);
if(target_mc != undefined){
this._x = getProperty(this._droptarget, _x);
this._y = getProperty(this._droptarget, _y);
target_mc = this._droptarget;
trace("target_mc value durring successful drop = "+target_mc);
} else {
trace("target_mc value durring unsuccessful drop = "+target_mc);
trace("origX = "+this.origX+" and initX = "+this.initX);
if(this.origX == this.initX){
trace("origX = "+this.origX+" and initX = "+this.initX);
this._x = this.origX;
this._y = this.origY;
target_mc = undefined;
}
//target_mc = undefined; test to see if the drag that occupied this item is what was moved...
trace("target_mc value durring unsuccessful drop2 = "+target_mc);
}
}
else
{
if(this.origX != this.initX){
trace("origX = "+this.origX+" and initX = "+this.initX);
this._x = this.origX;
this._y = this.origY;
target_mc = undefined;
}
trace("target_mc value durring outside drop = "+target_mc);
}
}
}
}
init();
Sorry for the jumbled code, I got to a &*%^ it point.
Thanks,
-Jason