[fmx] drop code with a counting varible problem

Hi everyone, I am having a big problem with some drag and drop code I am trying to write. Basically I have two lists of draggable components, the components and their symbols. The user has to drag the correct component with its matching symbol on drop area which are labelled.

When the user gets the right component in the right drop point it has a counter which keeps track of which single part is in the right place.

I am having trouble in making a counter which increases when two matching components are placed correctly and to decrease when either of the components are taken out of their correct place…my problem is that it will decrease when a components is just picked up and dropped back into the correct place.

If anyone understands my problem and can have a look at the code below I would really appreicate some advice around my problem.

Code fr one drag object (in this case a off switch)


onClipEvent (load) {
	this.dropped = 0;
	//setting dropped false at the beginning
	this.OrgX = this._x;
	this.OrgY = this._y;
}
on (press) {
	startDrag(this, true);
	this.swapDepths(100);
}
on (release) {
	this.gotoAndStop(1);
	if (this.hitTest(this._parent.DropOffSwitch)) {
		_root.nOffSwitch = 1;
		if (_root.nOffSwitch == 1 && _root.nOffSwitchSymbol == 1) {
			_root.ComponentsCorrect++;
			trace(_root.ComponentsCorrect);
		} 
		stopDrag();
		this.dropped = 1;
		this.swapDepths(1);
	} else if (this.hitTest(this._parent.CatchDrop)) {
		this._x = this.OrgX;
		this._y = this.OrgY;
		stopDrag();
		_root.DOffSwitch = 0;
		_root.OffSwitchLight.gotoAndStop(1);
		this.swapDepths(1);
		if (this.dropped=1) {
						_root.ComponentsCorrect--;
			trace(_root.ComponentsCorrect);
			//if dropped =true, it's in the mains and _root.MainsItems should be decreased 1
			_root.nOffSwitch = 0;
			this.dropped = 0;
			//setting dropped false again
		}
	} else if (this.hitTest(this._parent.CatchDrop1)) {
		this._x = this.OrgX;
		this._y = this.OrgY;
		stopDrag();
		_root.DOffSwitch = 0;
		_root.OffSwitchLight.gotoAndStop(1);
		this.swapDepths(1);
		if (this.dropped=1) {
						_root.ComponentsCorrect--;
			trace(_root.ComponentsCorrect);
			//if dropped =true, it's in the mains and _root.MainsItems should be decreased 1
			_root.nOffSwitch = 0;
			this.dropped = 0;
			//setting dropped false again
		}
	} else if (this.hitTest(this._parent.CatchDrop2)) {
		this._x = this.OrgX;
		this._y = this.OrgY;
		stopDrag();
		_root.DOffSwitch = 0;
		_root.OffSwitchLight.gotoAndStop(1);
		this.swapDepths(1);
		if (this.dropped=1) {
			//if dropped =true, it's in the mains and _root.MainsItems should be decreased 1
			_root.nOffSwitch = 0;
			this.dropped = 0;
			//setting dropped false again
		}
	} else if (this.hitTest(this._parent.CatchDrop3)) {
		this._x = this.OrgX;
		this._y = this.OrgY;
		stopDrag();
		_root.DOffSwitch = 0;
		_root.OffSwitchLight.gotoAndStop(1);
		this.swapDepths(1);
		if (this.dropped=1) {
			//if dropped =true, it's in the mains and _root.MainsItems should be decreased 1
			_root.nOffSwitch = 0;
			this.dropped = 0;
			//setting dropped false again
		}
	} else {
		stopDrag();
		_root.DOffSwitch = 0;
		_root.OffSwitchLight.gotoAndStop(1);
		this.swapDepths(1);
		if (this.dropped=1) {
			//if dropped =true, it's in the mains and _root.MainsItems should be decreased 1
			_root.nOffSwitch = 0;
			this.dropped = 0;
			//setting dropped false again
		}
	}
}


The catchdrop just sends it back if it is not in the right place…I apoligise for my lameness in AS…I know that my code is always way too long but I have a lot of variables which I need to pass and count etc…it made sense to me to write it the longest way possible. I know it’s a bad habit but I am still learning.

Any help would be hugly appreciated, Matt.

ps. Am i being rediculous with all this code? am I best off ripping it out and putting it in a small flash file to attach?