17-04-2013, 20:26
|
|
|
חבר מתאריך: 17.04.13
הודעות: 1
|
|
Drag & Drop
הסקריפט המצורף מבקש מהמשתמש לגרור 3 עצמים למטרה ל-3 מטרות שונות:
קוד:
function dragSetup(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged=true; }; clip.onRelease = clip.onReleaseOutside=function () { stopDrag(); this.beingDragged=false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; clip.myHomeX = clip._x; clip.myHomeY = clip._y; clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { if (!this.beingDragged && !this.onTarget) { this._x -= (this._x-this.myHomeX)/5; this._y -= (this._y-this.myHomeY)/5 } } ; } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x-this.myFinalX)/5; this._y -= (this._y-this.myFinalY)/5; } }; onEnterFrame=function(){ if(circle_mc.targetCircle == true && circle2_mc.targetCircle2 == true && Target3.onTarget == true ){ gotoAndStop(2) } dragSetup(circle_mc,targetCircle); dragSetup(circle2_mc,targetCircle2); dragSetup(circle3_mc,targetCircle3);
איך אפשר לבדוק שהמשתמש אכן גרר את כל 3 העצמים למטרות וברגע שסיים את הפעולה לטעון מוביקליפ חדש?
|