Drag and Drop Problem

... werden denn alle Verzweigungen bei Dir korrekt ausgeführt? ;)

Na, ich will mal nicht so sein:
Code:
var current = 0;
var max = 5; // Maximalanzahl;
var clones = new Array(max);
var currentClone = null;

for (var i=0; i<clones.length; i++) {
	clones[i] = false;
}

firstOne.onPress = function() {
	if (getAmt() >= max) return;
	currentClone = this.duplicateMovieClip("dup" + getTimer(), this._parent.getNextHighestDepth());
	doPush(currentClone);
	currentClone.idx = parseInt(getIdx(currentClone), 10);
	currentClone.bx = this._x;
	currentClone.by = this._y;
	currentClone.brother = _root.bgnd; // nimm kein reserviertes Wort!
	currentClone.tf.text = (currentClone.idx + 1);
	currentClone._alpha = 70; // kann weg
	currentClone.onRelease = currentClone.onReleaseOutside = function() {
		this.stopDrag();
		if (this._droptarget.indexOf("bgnd") > 0) {
			// mach nix!
		} else {
			goBack(this);
		}
	}
	currentClone.onPress = function() {
		this.startDrag();
	}
	currentClone.startDrag();
}

firstOne.onRelease = firstOne.onReleaseOutside = function() {
	currentClone.stopDrag();
	if (currentClone._droptarget.indexOf("bgnd") > 0) {
		// mach nix!
	} else {
		goBack(currentClone);
	}
}

function goBack(obj) {
	obj.onEnterFrame = function() {
		this._x += (this.bx - this._x) / 2;
		this._y += (this.by - this._y) / 2;
		if (Math.abs(this.bx - this._x) < 1 && Math.abs(this.by - this._y) < 1) {
			erase(this);
			this.removeMovieClip();
		}
	}
}

function getAmt() {
	var a = 0;
	for (var i=0; i<clones.length; i++) {
		if (clones[i] != false) {
			a ++;
		}
	}
	return a;
}

function getIdx(obj) {
	for (var i=0; i<clones.length; i++) {
		if (obj == clones[i]) {
			return i;
		}
	}
}

function doPush(obj) {
	for (var i=0; i<clones.length; i++) {
		if (clones[i] == false) {
			clones[i] = obj;
			return;
		}
	}
}

function erase(obj) {
	for (var i=0; i<clones.length; i++) {
		if (obj == clones[i]) {
			clones[i] = false;
			return;
		}
	}
}
Damit sollte es laufen. (Ich habe "background" mal in "bgnd" umbenannt, da es sich um ein reserviertes Wort handelt)

Gruß
.
 
Hab mir jetzt deine Antwort noch nicht genau angeguckt, aber ich habe es auch noch mal neu geschrieben und jetzt ging es. Ich weiß zwar nicht was ich jetzt anders gemacht habe, aber jetzt funktioniert es. Ich werd mir beides noch mal genau angucken und dann wird mir bestimmt ein Licht aufgehen!;)
 

Neue Beiträge

Zurück