Zurück   Flashforum > Flash > ActionScript > Spielkonzepte und Spieleprogrammierung

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 16-11-2006, 13:53   #1 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
Lük problem

Vielleicht kann mir jemand weiter helfen mit folgendem problem.
Ich hab eine art Drag und Drop gebaut die jetzt nur richtig gelegt werden kann! Es sollte aber so sien das man auch falsch droppen kan und das dan die drops auch schön centriert hinfallen auf die targets. Erst auf knopf druck wird dann kontroliert ob alles gut oder falsch liegt.
Ich glaub das spiel kennt man auch in D unter den name Lük!

Code:
#include "111_002_002_002.txt"
allDragged = 0;
//links rechts associatie
dragSetup(drop1, target9);
dragSetup(drop2, target7);
dragSetup(drop3, target12);
dragSetup(drop4, target10);
dragSetup(drop5, target5);
dragSetup(drop6, target8);
dragSetup(drop7, target1);
dragSetup(drop8, target3);
dragSetup(drop9, target11);
dragSetup(drop10, target6);
dragSetup(drop11, target4);
dragSetup(drop12, target2);
dragSetup(drop13, target16);
dragSetup(drop14, target15);
dragSetup(drop15, target13);
dragSetup(drop16, target14);
//
function dragSetup(clip, targ) {
	clip.onPress = function() {
		startDrag(this);
		this.beingDragged = true;
		this.swapDepths(_root.getNextHighestDepth());
	};
	clip.onRelease = clip.onReleaseOutside=function () {
		stopDrag();
		this.beingDragged = false;
		if (eval(this._droptarget) == targ) {
			this.onTarget = true;
			// targ.gotoAndStop("goed");
		} else {
			this.onTarget = false;
			// targ.gotoAndStop("fout");
		}
	};

	//the variables below will store the clips starting position
	clip.myHomeX = clip._x;
	clip.myHomeY = clip._y;
	//the variables below will store the clips end position
	clip.myFinalX = targ._x;
	clip.myFinalY = targ._y;
	clip.onEnterFrame = function() {
		//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
		// then move the MC back to its original starting point (with a smooth motion)"
		if (!this.beingDragged && !this.onTarget) {
			this._x -= (this._x-this.myHomeX)/3;
			this._y -= (this._y-this.myHomeY)/3;
			//if the circle is dropped on any part of the target it slides to the center of the target
		} else if (!this.beingDragged && this.onTarget) {
			this._x -= (this._x-this.myFinalX)/3;
			this._y -= (this._y-this.myFinalY)/3;
		}
	};
}
//check if all stones are dragged
_root.onEnterFrame = function() {
	if (_root.allDragged == 16) {
		_root.endComment = "Nog een keer?";
	}
};
// control button 
control.onPress = function() {
	if (_root.drop1._droptarget == "/target9") {
		drop1._visible = false;
		_root.target9.gotoAndStop("goed");
	} else {
		_root.target9.gotoAndStop("fout");
	}
	if (_root.drop2._droptarget == "/target7") {
		drop2._visible = false;
		_root.target7.gotoAndStop("goed");
	} else {
		_root.target7.gotoAndStop("fout");
	}
	if (_root.drop3._droptarget == "/target12") {
		drop3._visible = false;
		_root.target12.gotoAndStop("goed");
	} else {
		_root.target12.gotoAndStop("fout");
	}
	if (_root.drop4._droptarget == "/target10") {
		drop4._visible = false;
		_root.target10.gotoAndStop("goed");
	} else {
		_root.target10.gotoAndStop("fout");
	}
	if (_root.drop5._droptarget == "/target5") {
		drop5._visible = false;
		_root.target5.gotoAndStop("goed");
	} else {
		_root.target5.gotoAndStop("fout");
	}
	if (_root.drop6._droptarget == "/target8") {
		drop6._visible = false;
		_root.target8.gotoAndStop("goed");
	} else {
		_root.target8.gotoAndStop("fout");
	}
	if (_root.drop7._droptarget == "/target1") {
		drop7._visible = false;
		_root.target1.gotoAndStop("goed");
	} else {
		_root.target1.gotoAndStop("fout");
	}
	if (_root.drop8._droptarget == "/target3") {
		drop8._visible = false;
		_root.target3.gotoAndStop("goed");
	} else {
		_root.target3.gotoAndStop("fout");
	}
	if (_root.drop9._droptarget == "/target11") {
		drop9._visible = false;
		_root.target11.gotoAndStop("goed");
	} else {
		_root.target11.gotoAndStop("fout");
	}
	if (_root.drop10._droptarget == "/target6") {
		drop10._visible = false;
		_root.target6.gotoAndStop("goed");
	} else {
		_root.target6.gotoAndStop("fout");
	}
	if (_root.drop11._droptarget == "/target4") {
		drop11._visible = false;
		_root.target4.gotoAndStop("goed");
	} else {
		_root.target4.gotoAndStop("fout");
	}
	if (_root.drop12._droptarget == "/target2") {
		drop12._visible = false;
		_root.target2.gotoAndStop("goed");
	} else {
		_root.target2.gotoAndStop("fout");
	}
	if (_root.drop13._droptarget == "/target16") {
		drop13._visible = false;
		_root.target16.gotoAndStop("goed");
	} else {
		_root.target16.gotoAndStop("fout");
	}
	if (_root.drop14._droptarget == "/target15") {
		drop14._visible = false;
		_root.target15.gotoAndStop("goed");
	} else {
		_root.target15.gotoAndStop("fout");
	}
	if (_root.drop15._droptarget == "/target13") {
		drop15._visible = false;
		_root.target13.gotoAndStop("goed");
	} else {
		_root.target13.gotoAndStop("fout");
	}
	if (_root.drop16._droptarget == "/target14") {
		drop16._visible = false;
		_root.target14.gotoAndStop("goed");
	} else {
		_root.target14.gotoAndStop("fout");
	}
};
Huub ist offline   Mit Zitat antworten
Alt 28-11-2006, 14:51   #2 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
Soweit bin ich selber bis jetzt gekommen aber es funkt immer noch nicht!
SWF datei ist als beispiel im zip.

PHP-Code:
#include "111_002_002_002.txt"
//links rechts associatie
dragSetup(drop1target9);
dragSetup(drop2target7);
dragSetup(drop3target12);
dragSetup(drop4target10);
dragSetup(drop5target5);
dragSetup(drop6target8);
dragSetup(drop7target1);
dragSetup(drop8target3);
dragSetup(drop9target11);
dragSetup(drop10target6);
dragSetup(drop11target4);
dragSetup(drop12target2);
dragSetup(drop13target16);
dragSetup(drop14target15);
dragSetup(drop15target13);
dragSetup(drop16target14);
//
function dragSetup(cliptarg) {
    
clip.onPress = function() {
        
startDrag(this);
        
this.beingDragged true;
        
this.swapDepths(_root.getNextHighestDepth());
        
clip.t1 0;
        
clip.t2 0;
        
clip.t3 0;
        
clip.t4 0;
        
clip.t5 0;
        
clip.t6 0;
        
clip.t7 0;
        
clip.t8 0;
        
clip.t9 0;
        
clip.t10 0;
        
clip.t11 0;
        
clip.t12 0;
        
clip.t13 0;
        
clip.t14 0;
        
clip.t15 0;
        
clip.t16 0;
    };
    
clip.onRelease clip.onReleaseOutside=function () {
        
trace("button up");
        
stopDrag();
        
this.beingDragged false;
        if (eval(
this._droptarget) == targ) {
            
this.onTarget true;
            
// targ.gotoAndStop("goed");
        
} else {
            
this.onTarget false;
            
// targ.gotoAndStop("fout");
        
}
    };
    
//the variables below will store the clips starting position
    
clip.myHomeX clip._x;
    
clip.myHomeY clip._y;
    
//the variables below will store the clips end position
    
clip.myFinalX targ._x;
    
clip.myFinalY targ._y;
    
//
    
clip.onEnterFrame = function() {
        
//if the circle is dropped on any part of the target it slides to the center of the target     
        
if (!this.beingDragged && !this.onTarget) {
            
//&& !this.onGrid) {
            
if (this.hitTest(_root.target1) == true && clip.t1 == 0) {
                
clip.t1 1;
                
this._x _root.target1._x;
                
this._y _root.target1._y;
            }
            if (
this.hitTest(_root.target2) == true && clip.t2 == 0) {
                
clip.t2 1;
                
this._x _root.target2._x;
                
this._y _root.target2._y;
            }
            if (
this.hitTest(_root.target3) == true && clip.t3 == 0) {
                
clip.t3 1;
                
trace(t3);
                
this._x _root.target3._x;
                
this._y _root.target3._y;
            }
            if (
this.hitTest(_root.target4) == true && clip.t4 == 0) {
                
clip.t4 1;
                
trace(t4);
                
this._x _root.target4._x;
                
this._y _root.target4._y;
            }
            if (
this.hitTest(_root.target5) == true && clip.t5 == 0) {
                
clip.t5 1;
                
this._x _root.target5._x;
                
this._y _root.target5._y;
            }
            if (
this.hitTest(_root.target6) == true && clip.t6 == 0) {
                
clip.t6 1;
                
this._x _root.target6._x;
                
this._y _root.target6._y;
            }
            if (
this.hitTest(_root.target7) == true && clip.t7 == 0) {
                
clip.t7 1;
                
this._x _root.target7._x;
                
this._y _root.target7._y;
            }
            if (
this.hitTest(_root.target8) == true && clip.t8 == 0) {
                
clip.t8 1;
                
this._x _root.target8._x;
                
this._y _root.target8._y;
            }
            if (
this.hitTest(_root.target9) == true && clip.t9 == 0) {
                
clip.t9 1;
                
this._x _root.target9._x;
                
this._y _root.target9._y;
            }
            if (
this.hitTest(_root.target10) == true && clip.t10 == 0) {
                
clip.t10 1;
                
this._x _root.target10._x;
                
this._y _root.target10._y;
            }
            if (
this.hitTest(_root.target11) == true && clip.t11 == 0) {
                
clip.t11 1;
                
this._x _root.target11._x;
                
this._y _root.target11._y;
            }
            if (
this.hitTest(_root.target12) == true && clip.t12 == 0) {
                
clip.t12 1;
                
this._x _root.target12._x;
                
this._y _root.target12._y;
            }
            if (
this.hitTest(_root.target13) == true && clip.t13 == 0) {
                
clip.t13 1;
                
this._x _root.target13._x;
                
this._y _root.target13._y;
            }
            if (
this.hitTest(_root.target14) == true && clip.t14 == 0) {
                
clip.t14 1;
                
this._x _root.target14._x;
                
this._y _root.target14._y;
            }
            if (
this.hitTest(_root.target15) == true && clip.t15 == 0) {
                
clip.t15 1;
                
this._x _root.target15._x;
                
this._y _root.target15._y;
            }
            if (
this.hitTest(_root.target16) == true && clip.t16 == 0) {
                
clip.t16 1;
                
this._x _root.target16._x;
                
this._y _root.target16._y;
            }
            
/*
            } else if (!this.beingDragged && !this.onTarget) {
            this._x -= (this._x-this.myHomeX)/3;
            this._y -= (this._y-this.myHomeY)/3;
            } else {
            (!this.beingDragged && this.onTarget);
            this._x -= (this._x-this.myFinalX)/3;
            this._y -= (this._y-this.myFinalY)/3;
            */ 
        
}
    };
}
// 
//check if all stones are dragged
// control button 
control.onPress = function() {
    if (
_root.drop1._droptarget == "/target9") {
        
drop1._visible false;
        
_root.target9.gotoAndStop("goed");
    } else {
        
_root.target9.gotoAndStop("fout");
    }
    if (
_root.drop2._droptarget == "/target7") {
        
drop2._visible false;
        
_root.target7.gotoAndStop("goed");
    } else {
        
_root.target7.gotoAndStop("fout");
    }
    if (
_root.drop3._droptarget == "/target12") {
        
drop3._visible false;
        
_root.target12.gotoAndStop("goed");
    } else {
        
_root.target12.gotoAndStop("fout");
    }
    if (
_root.drop4._droptarget == "/target10") {
        
drop4._visible false;
        
_root.target10.gotoAndStop("goed");
    } else {
        
_root.target10.gotoAndStop("fout");
    }
    if (
_root.drop5._droptarget == "/target5") {
        
drop5._visible false;
        
_root.target5.gotoAndStop("goed");
    } else {
        
_root.target5.gotoAndStop("fout");
    }
    if (
_root.drop6._droptarget == "/target8") {
        
drop6._visible false;
        
_root.target8.gotoAndStop("goed");
    } else {
        
_root.target8.gotoAndStop("fout");
    }
    if (
_root.drop7._droptarget == "/target1") {
        
drop7._visible false;
        
_root.target1.gotoAndStop("goed");
    } else {
        
_root.target1.gotoAndStop("fout");
    }
    if (
_root.drop8._droptarget == "/target3") {
        
drop8._visible false;
        
_root.target3.gotoAndStop("goed");
    } else {
        
_root.target3.gotoAndStop("fout");
    }
    if (
_root.drop9._droptarget == "/target11") {
        
drop9._visible false;
        
_root.target11.gotoAndStop("goed");
    } else {
        
_root.target11.gotoAndStop("fout");
    }
    if (
_root.drop10._droptarget == "/target6") {
        
drop10._visible false;
        
_root.target6.gotoAndStop("goed");
    } else {
        
_root.target6.gotoAndStop("fout");
    }
    if (
_root.drop11._droptarget == "/target4") {
        
drop11._visible false;
        
_root.target4.gotoAndStop("goed");
    } else {
        
_root.target4.gotoAndStop("fout");
    }
    if (
_root.drop12._droptarget == "/target2") {
        
drop12._visible false;
        
_root.target2.gotoAndStop("goed");
    } else {
        
_root.target2.gotoAndStop("fout");
    }
    if (
_root.drop13._droptarget == "/target16") {
        
drop13._visible false;
        
_root.target16.gotoAndStop("goed");
    } else {
        
_root.target16.gotoAndStop("fout");
    }
    if (
_root.drop14._droptarget == "/target15") {
        
drop14._visible false;
        
_root.target15.gotoAndStop("goed");
    } else {
        
_root.target15.gotoAndStop("fout");
    }
    if (
_root.drop15._droptarget == "/target13") {
        
drop15._visible false;
        
_root.target13.gotoAndStop("goed");
    } else {
        
_root.target13.gotoAndStop("fout");
    }
    if (
_root.drop16._droptarget == "/target14") {
        
drop16._visible false;
        
_root.target14.gotoAndStop("goed");
    } else {
        
_root.target14.gotoAndStop("fout");
    }
}; 
Angehängte Dateien
Dateityp: zip 111_002_002_002_versie7.zip (25,7 KB, 7x aufgerufen)
Huub ist offline   Mit Zitat antworten
Alt 28-11-2006, 14:53   #3 (permalink)
Flashbitch
 
Benutzerbild von X-Tender
 
Registriert seit: Oct 2003
Ort: Hannover
Beiträge: 279
AUA! Das hätte man aber auch kürzer machen können :x
__________________
Fuchtelworld
X-Tender ist offline   Mit Zitat antworten
Alt 29-11-2006, 09:10   #4 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
Wie?

Oké kurzer wäre schon! Aber erst muss der Fehler raus.
Im clip springen immer noch alle drops auf target16.
Also bin mir noch nicht sicher ob dei hittest in die onEnterframe funktion soll.
So wie sie jetzt steht laufts nicht!
Huub ist offline   Mit Zitat antworten
Alt 29-11-2006, 15:55   #5 (permalink)
Flashbitch
 
Benutzerbild von X-Tender
 
Registriert seit: Oct 2003
Ort: Hannover
Beiträge: 279
schmiess die 1000 if abfragen aus und ersetze sie mit schleifen. anders macht es kein sin sowas zu debuggen!
__________________
Fuchtelworld
X-Tender ist offline   Mit Zitat antworten
Alt 29-11-2006, 16:05   #6 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
nur die function

PHP-Code:
dragSetup(drop1target9);
dragSetup(drop2target7);
dragSetup(drop3target12);
dragSetup(drop4target10);
dragSetup(drop5target5);
dragSetup(drop6target8);
dragSetup(drop7target1);
dragSetup(drop8target3);
dragSetup(drop9target11);
dragSetup(drop10target6);
dragSetup(drop11target4);
dragSetup(drop12target2);
dragSetup(drop13target16);
dragSetup(drop14target15);
dragSetup(drop15target13);
dragSetup(drop16target14);
//
function dragSetup(cliptarg) {
    
clip.onPress = function() {
        
startDrag(this);
        
this.beingDragged true;
        
this.swapDepths(_root.getNextHighestDepth());
    };
    
clip.onRelease clip.onReleaseOutside=function () {
        
stopDrag();
        
this.beingDragged false;
        if (eval(
this._droptarget) == targ) {
            
this.onTarget true;
        } else {
            
this.onTarget false;
        }
    };
    
//the variables below will store the clips starting position   
    
clip.myHomeX clip._x;
    
clip.myHomeY clip._y;
    
//the variables below will store the clips end position
    
clip.myFinalX targ._x;
    
clip.myFinalY targ._y;
    
clip.onEnterFrame = function() {
        
//if the circle is dropped on any part of the target it slides to the center of the target     
        
if (!this.beingDragged && !this.onTarget) {
            
this._x -= (this._x-this.myHomeX)/3;
            
this._y -= (this._y-this.myHomeY)/3;
        } else {
            (!
this.beingDragged && this.onTarget);
            
this._x -= (this._x-this.myFinalX)/3;
            
this._y -= (this._y-this.myFinalY)/3;
        }
    };

Und jetzt möchte ich eigentlich das skript ausbauen so das es auch möglich ist falsch zu droppen? Und da kom ich nicht weiter!
Huub ist offline   Mit Zitat antworten
Alt 30-11-2006, 14:58   #7 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
Bis sowiet klapt es jetzt

PHP-Code:
var grid:Array = Array(target1target2target3target4target5target6target7target8target9target10target11target12target13target14target15target16);
//links rechts associatie
dragSetup(drop1target9);
dragSetup(drop2target7);
dragSetup(drop3target12);
dragSetup(drop4target10);
dragSetup(drop5target5);
dragSetup(drop6target8);
dragSetup(drop7target1);
dragSetup(drop8target3);
dragSetup(drop9target11);
dragSetup(drop10target6);
dragSetup(drop11target4);
dragSetup(drop12target2);
dragSetup(drop13target16);
dragSetup(drop14target15);
dragSetup(drop15target13);
dragSetup(drop16target14);
//
function dragSetup(cliptarg) {
    
clip.onPress = function() {
        
startDrag(this);
        
this.beingDragged true;
        
this.swapDepths(_root.getNextHighestDepth());
    };
    
clip.onRelease clip.onReleaseOutside=function () {
        
stopDrag();
        
this.inArray false;
        var 
i:Number;
        for (
i=0i<16i++) {
            if (eval(
this._droptarget) == grid[i]) {
                
this.inArray true;
                
this.near i;
            }
        }
        
this.beingDragged false;
        if (eval(
this._droptarget) == targ) {
            
this.onTarget true;
            
// targ.gotoAndStop("goed");
        
} else if (this.inArray == true) {
            
this.onGrid true;
            
// targ.gotoAndStop("fout");
        
} else {
            
this.onTarget false;
            
// targ.gotoAndStop("fout");
        
}
    };
    
//the variables below will store the clips starting position
    
clip.myHomeX clip._x;
    
clip.myHomeY clip._y;
    
//the variables below will store the clips end position
    
clip.myFinalX targ._x;
    
clip.myFinalY targ._y;
    
//the variables below will store the current position
    //
    
clip.onEnterFrame = function() {
        switch (
this.near) {
        case 
:
            
clip.myX target1._x;
            
clip.myY target1._y;
            break;
        case 
:
            
clip.myX target2._x;
            
clip.myY target2._y;
            break;
        case 
:
            
clip.myX target3._x;
            
clip.myY target3._y;
            break;
        case 
:
            
clip.myX target4._x;
            
clip.myY target4._y;
            break;
        case 
:
            
clip.myX target5._x;
            
clip.myY target5._y;
            break;
        case 
:
            
clip.myX target6._x;
            
clip.myY target6._y;
            break;
        case 
:
            
clip.myX target7._x;
            
clip.myY target7._y;
            break;
        case 
:
            
clip.myX target8._x;
            
clip.myY target8._y;
            break;
        case 
:
            
clip.myX target9._x;
            
clip.myY target9._y;
            break;
        case 
:
            
clip.myX target10._x;
            
clip.myY target10._y;
            break;
        case 
10 :
            
clip.myX target11._x;
            
clip.myY target11._y;
            break;
        case 
11 :
            
clip.myX target12._x;
            
clip.myY target12._y;
            break;
        case 
12 :
            
clip.myX target13._x;
            
clip.myY target13._y;
            break;
        case 
13 :
            
clip.myX target14._x;
            
clip.myY target14._y;
            break;
        case 
14 :
            
clip.myX target15._x;
            
clip.myY target15._y;
            break;
        case 
15 :
            
clip.myX target16._x;
            
clip.myY target16._y;
            break;
        }
        if (!
this.beingDragged && !this.onTarget && !this.onGrid) {
            
this._x -= (this._x-this.myHomeX)/3;
            
this._y -= (this._y-this.myHomeY)/3;
            
//if the circle is dropped on any part of the target it slides to the center of the target
        
} else if (!this.beingDragged && !this.onTarget && this.onGrid) {
            
this._x -= (this._x-this.myX)/3;
            
this._y -= (this._y-this.myY)/3;
        } else if (!
this.beingDragged && this.onTarget) {
            
this._x -= (this._x-this.myFinalX)/3;
            
this._y -= (this._y-this.myFinalY)/3;
        }
    };

Oder hat noch jemand eine bessere (kurzere) lösung?
Huub ist offline   Mit Zitat antworten
Alt 30-11-2006, 16:04   #8 (permalink)
Flashbitch
 
Benutzerbild von X-Tender
 
Registriert seit: Oct 2003
Ort: Hannover
Beiträge: 279
Zitat:
Zitat von Huub Beitrag anzeigen
PHP-Code:
var grid:Array = Array(target1target2target3target4target5target6target7target8target9target10target11target12target13target14target15target16);
//links rechts associatie
dragSetup(drop1target9);
dragSetup(drop2target7);
dragSetup(drop3target12);
dragSetup(drop4target10);
dragSetup(drop5target5);
dragSetup(drop6target8);
dragSetup(drop7target1);
dragSetup(drop8target3);
dragSetup(drop9target11);
dragSetup(drop10target6);
dragSetup(drop11target4);
dragSetup(drop12target2);
dragSetup(drop13target16);
dragSetup(drop14target15);
dragSetup(drop15target13);
dragSetup(drop16target14);
//
function dragSetup(cliptarg) {
    
clip.onPress = function() {
        
startDrag(this);
        
this.beingDragged true;
        
this.swapDepths(_root.getNextHighestDepth());
    };
    
clip.onRelease clip.onReleaseOutside=function () {
        
stopDrag();
        
this.inArray false;
        var 
i:Number;
        for (
i=0i<16i++) {
            if (eval(
this._droptarget) == grid[i]) {
                
this.inArray true;
                
this.near i;
            }
        }
        
this.beingDragged false;
        if (eval(
this._droptarget) == targ) {
            
this.onTarget true;
            
// targ.gotoAndStop("goed");
        
} else if (this.inArray == true) {
            
this.onGrid true;
            
// targ.gotoAndStop("fout");
        
} else {
            
this.onTarget false;
            
// targ.gotoAndStop("fout");
        
}
    };
    
//the variables below will store the clips starting position
    
clip.myHomeX clip._x;
    
clip.myHomeY clip._y;
    
//the variables below will store the clips end position
    
clip.myFinalX targ._x;
    
clip.myFinalY targ._y;
    
//the variables below will store the current position
    //
    
clip.onEnterFrame = function() {
        
clip.myX _root["target"+(this.near+1)]._x;
        
clip.myY _root["target"+(this.near+1)]._y;

        if (!
this.beingDragged && !this.onTarget && !this.onGrid) {
            
this._x -= (this._x-this.myHomeX)/3;
            
this._y -= (this._y-this.myHomeY)/3;
            
//if the circle is dropped on any part of the target it slides to the center of the target
        
} else if (!this.beingDragged && !this.onTarget && this.onGrid) {
            
this._x -= (this._x-this.myX)/3;
            
this._y -= (this._y-this.myY)/3;
        } else if (!
this.beingDragged && this.onTarget) {
            
this._x -= (this._x-this.myFinalX)/3;
            
this._y -= (this._y-this.myFinalY)/3;
        }
    };

Oder hat noch jemand eine bessere (kurzere) lösung?
Und wozu die evals?
__________________
Fuchtelworld
X-Tender ist offline   Mit Zitat antworten
Alt 01-12-2006, 09:09   #9 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
ohne evals

PHP-Code:
//if (eval(this._droptarget) == grid[i]) {
            
if (this._droptarget == grid[i]) { 
und
PHP-Code:
//if (eval(this._droptarget) == targ) {
        
if (this._droptarget == targ) { 
Ich hab versucht die evals raus zu holen aber ich mach irgendwas falsch.
Help?
Huub ist offline   Mit Zitat antworten
Alt 01-12-2006, 09:26   #10 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
so?

PHP-Code:
//if (eval(this._droptarget) == grid[i]) {
            
if (this[this._droptarget] == grid[i]) { 
und
PHP-Code:
//if (eval(this._droptarget) == targ) {
        
if (this[this._droptarget] == targ) { 

richtig geschrieben? aber irgendwie nicht das gleiche?!
Huub ist offline   Mit Zitat antworten
Alt 01-12-2006, 09:50   #11 (permalink)
Flashbitch
 
Benutzerbild von X-Tender
 
Registriert seit: Oct 2003
Ort: Hannover
Beiträge: 279
Ok ich sehe das haben die in der HIlfe auch so gemacht.. hae noch nie mit droptarget gearbeitet deshalb ..
__________________
Fuchtelworld
X-Tender ist offline   Mit Zitat antworten
Alt 01-12-2006, 09:57   #12 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
eval conform as2!?

Einerseits wird gesagt eval is nicht conform AS2 anderseits wirds in _droptarget (MovieClip._droptarget property) als beispiel benutzt.
Huub ist offline   Mit Zitat antworten
Alt 07-12-2006, 16:23   #13 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
bis soweit

PHP-Code:
var grid:Array = Array(target1target2target3target4target5target6target7target8target9target10target11target12target13target14target15target16);
var 
drop:Array = Array(drop1drop2drop3drop4drop5drop6drop7drop8drop9drop10drop11drop12drop13drop14drop15drop16);
var 
full:Number = Array();
//links rechts associatie
dragSetup(drop1target9);
dragSetup(drop2target7);
dragSetup(drop3target12);
dragSetup(drop4target10);
dragSetup(drop5target5);
dragSetup(drop6target8);
dragSetup(drop7target1);
dragSetup(drop8target3);
dragSetup(drop9target11);
dragSetup(drop10target6);
dragSetup(drop11target4);
dragSetup(drop12target2);
dragSetup(drop13target16);
dragSetup(drop14target15);
dragSetup(drop15target13);
dragSetup(drop16target14);
//
function dragSetup(cliptarg) {
    
clip.onPress = function() {
        
startDrag(this);
        
this.beingDragged true;
        
this.swapDepths(_root.getNextHighestDepth());
    };
    
clip.onRelease clip.onReleaseOutside=function () {
        
stopDrag();
        
this.inArray false;
        var 
i:Number;
        for (
i=0i<16i++) {
            if (eval(
this._droptarget) == grid[i]) {
                
this.inArray true;
                
this.near i;
                
full[i] = 1;
                
//trace(full);
            
}
        }
        
this.beingDragged false;
        if (eval(
this._droptarget) == targ) {
            
this.onTarget true;
            
this.onGrid false;
            
//targ.gotoAndStop("goed");
        
} else if (this.inArray == true) {
            
this.onTarget false;
            
this.onGrid true;
            
// targ.gotoAndStop("fout");
        
} else {
            
this.onTarget false;
            
this.onGrid false;
            
// targ.gotoAndStop("fout");
        
}
    };
    
//the variables below will store the clips starting position
    
clip.myHomeX clip._x;
    
clip.myHomeY clip._y;
    
//the variables below will store the clips end position
    
clip.myFinalX targ._x;
    
clip.myFinalY targ._y;
    
//the variables below will store the current position
    //
    
clip.onEnterFrame = function() {
        switch (
this.near) {
        case 
:
            
clip.myX target1._x;
            
clip.myY target1._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target2._x;
            
clip.myY target2._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target3._x;
            
clip.myY target3._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target4._x;
            
clip.myY target4._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target5._x;
            
clip.myY target5._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target6._x;
            
clip.myY target6._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target7._x;
            
clip.myY target7._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target8._x;
            
clip.myY target8._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target9._x;
            
clip.myY target9._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target10._x;
            
clip.myY target10._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
10 :
            
clip.myX target11._x;
            
clip.myY target11._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
11 :
            
clip.myX target12._x;
            
clip.myY target12._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
12 :
            
clip.myX target13._x;
            
clip.myY target13._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
13 :
            
clip.myX target14._x;
            
clip.myY target14._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
14 :
            
clip.myX target15._x;
            
clip.myY target15._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
15 :
            
clip.myX target16._x;
            
clip.myY target16._y;
            
// targ.gotoAndStop("fout");
            
break;
        }
        if (!
this.beingDragged && !this.onTarget && !this.onGrid) {
            
this._x -= (this._x-this.myHomeX)/3;
            
this._y -= (this._y-this.myHomeY)/3;
            
//if the circle is dropped on any part of the target it slides to the center of the target
        
} else if (!this.beingDragged && !this.onTarget && this.onGrid) {
            
this._x -= (this._x-this.myX)/3;
            
this._y -= (this._y-this.myY)/3;
        } else if (!
this.beingDragged && this.onTarget) {
            
this._x -= (this._x-this.myFinalX)/3;
            
this._y -= (this._y-this.myFinalY)/3;
        }
    };
}
//
//check if all stones are on grid / all stones are dragged
// control button 
control.onPress = function() {
    
trace(full);
    if ((
full[1] == 1) && (full[2] == 1) && (full[3] == 1) && (full[4] == 1) && (full[5] == 1) && (full[6] == 1)&& (full[7] == 1)&& (full[8] == 1)&& (full[9] == 1)&& (full[10] == 1)&& (full[11] == 1)&& (full[12] == 1)&& (full[13] == 1)&& (full[14] == 1)&& (full[15] == 1)&& (full[16] == 1)) {
        
trace("message");
        if (
_root.drop1._droptarget == "/target9") {
            
drop1._visible false;
            
_root.target9.gotoAndStop("goed");
        } else {
            
drop1._visible false;
            
_root.target9.gotoAndStop("fout");
        }
        if (
_root.drop2._droptarget == "/target7") {
            
drop2._visible false;
            
_root.target7.gotoAndStop("goed");
        } else {
            
drop2._visible false;
            
_root.target7.gotoAndStop("fout");
        }
        if (
_root.drop3._droptarget == "/target12") {
            
drop3._visible false;
            
_root.target12.gotoAndStop("goed");
        } else {
            
drop3._visible false;
            
_root.target12.gotoAndStop("fout");
        }
        if (
_root.drop4._droptarget == "/target10") {
            
drop4._visible false;
            
_root.target10.gotoAndStop("goed");
        } else {
            
drop4._visible false;
            
_root.target10.gotoAndStop("fout");
        }
        if (
_root.drop5._droptarget == "/target5") {
            
drop5._visible false;
            
_root.target5.gotoAndStop("goed");
        } else {
            
drop5._visible false;
            
_root.target5.gotoAndStop("fout");
        }
        if (
_root.drop6._droptarget == "/target8") {
            
drop6._visible false;
            
_root.target8.gotoAndStop("goed");
        } else {
            
drop6._visible false;
            
_root.target8.gotoAndStop("fout");
        }
        if (
_root.drop7._droptarget == "/target1") {
            
drop7._visible false;
            
_root.target1.gotoAndStop("goed");
        } else {
            
drop7._visible false;
            
_root.target1.gotoAndStop("fout");
        }
        if (
_root.drop8._droptarget == "/target3") {
            
drop8._visible false;
            
_root.target3.gotoAndStop("goed");
        } else {
            
drop8._visible false;
            
_root.target3.gotoAndStop("fout");
        }
        if (
_root.drop9._droptarget == "/target11") {
            
drop9._visible false;
            
_root.target11.gotoAndStop("goed");
        } else {
            
drop9._visible false;
            
_root.target11.gotoAndStop("fout");
        }
        if (
_root.drop10._droptarget == "/target6") {
            
drop10._visible false;
            
_root.target6.gotoAndStop("goed");
        } else {
            
drop10._visible false;
            
_root.target6.gotoAndStop("fout");
        }
        if (
_root.drop11._droptarget == "/target4") {
            
drop11._visible false;
            
_root.target4.gotoAndStop("goed");
        } else {
            
drop11._visible false;
            
_root.target4.gotoAndStop("fout");
        }
        if (
_root.drop12._droptarget == "/target2") {
            
drop12._visible false;
            
_root.target2.gotoAndStop("goed");
        } else {
            
drop12._visible false;
            
_root.target2.gotoAndStop("fout");
        }
        if (
_root.drop13._droptarget == "/target16") {
            
drop13._visible false;
            
_root.target16.gotoAndStop("goed");
        } else {
            
drop13._visible false;
            
_root.target16.gotoAndStop("fout");
        }
        if (
_root.drop14._droptarget == "/target15") {
            
drop14._visible false;
            
_root.target15.gotoAndStop("goed");
        } else {
            
drop14._visible false;
            
_root.target15.gotoAndStop("fout");
        }
        if (
_root.drop15._droptarget == "/target13") {
            
drop15._visible false;
            
_root.target13.gotoAndStop("goed");
        } else {
            
drop15._visible false;
            
_root.target13.gotoAndStop("fout");
        }
        if (
_root.drop16._droptarget == "/target14") {
            
drop16._visible false;
            
_root.target14.gotoAndStop("goed");
        } else {
            
drop16._visible false;
            
_root.target14.gotoAndStop("fout");
        }
    }
}; 
Bis soweit bin ich jetzt selber gekommen aber frag mich immer noch ob mir keiner zeigen kann wie es kluger geht!
Huub ist offline   Mit Zitat antworten
Alt 07-12-2006, 16:48   #14 (permalink)
muh
 
Benutzerbild von Janoscharlipp
 
Registriert seit: Apr 2002
Ort: Freiburg / Stuttgart
Beiträge: 4.338
"Schleife" heitßt das Zauberwort

Damit kannst du das letzte If-Gedöns loswerden, falls sich die Kombinationen nicht berechnen lassen, legst du sie in einem Array (oder einem Objekt) ab, und gehst dieses dann in einer Schleife durch.

Das switch
PHP-Code:
switch (this.near) {
        case 
:
            
clip.myX target1._x;
            
clip.myY target1._y;
            
// targ.gotoAndStop("fout");
            
break;
        case 
:
            
clip.myX target2._x;
            
clip.myY target2._y
// ... 
kannst du ersetzen durch:
PHP-Code:
var target MovieClip this["target" + (this.near 1)];
clip.myX target._x;
clip.myY target._y
__________________
»Carpe diem«, sagte der Graf. (Terry Pratchett: Ruhig Blut!)
Janoscharlipp ist offline   Mit Zitat antworten
Alt 08-12-2006, 08:14   #15 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Venlo Niederlande
Beiträge: 23
Schleiffe oké - macht sin! Aber?

PHP-Code:
clip.onEnterFrame = function() {
        var 
target:MovieClip this["target"+(this.near+1)];
        
clip.myX target._x;
        
clip.myY target._y;
        
//
        
if (!this.beingDragged && !this.onTarget && !this.onGrid) {
            
this._x -= (this._x-this.myHomeX)/3;
            
this._y -= (this._y-this.myHomeY)/3;
            
//if the circle is dropped on any part of the target it slides to the center of the target
        
} else if (!this.beingDragged && !this.onTarget && this.onGrid) {
            
this._x -= (this._x-this.myX)/3;
            
this._y -= (this._y-this.myY)/3;
        } else if (!
this.beingDragged && this.onTarget) {
            
this._x -= (this._x-this.myFinalX)/3;
            
this._y -= (this._y-this.myFinalY)/3;
        }
    }; 
Oké also wie oben!? Begreif ich!
Probleem isst das
PHP-Code:
        } else if (!this.beingDragged && !this.onTarget && this.onGrid) {
            
this._x -= (this._x-this.myX)/3;
            
this._y -= (this._y-this.myY)/3
jetzt nicht mehr funktioniert? Aber wie kommt das?
Angehängte Dateien
Dateityp: zip 111_002_002_002_versie12.zip (25,7 KB, 2x aufgerufen)
Huub ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 18:20 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele