A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Resetting MC's to Original Place

  1. #1
    Back to FK Boards!
    Join Date
    Apr 2006
    Location
    Troy
    Posts
    234

    Post Resetting MC's to Original Place

    Hi, I am creating a drum machine.

    Right now I am in the beginning stages and I have it set up so you can drag different sounds to the timeline (in the game, not in flash) and it'll snap in place which works perfectly.

    But here's my problem: When I try to click the reset button the sounds snap to their original places (which sounds good right?) but then they tween back to where you dragged them on the in-game timeline.

    I have put in various codes and no matter what I try, when I click the reset button, they always go back to where you dragged them to the timeline, making the reset button pointless.

    Here's my code on the Flash timeline:

    Code:
    function dragSetup(clip, targArray) {
    	clip.onPress = function() {
    		startDrag(this);
    		this.beingDragged = true;
    	};
    	var fonTarget:Boolean = false;
    	clip.onRelease = clip.onReleaseOutside=function () {
    		stopDrag();
    		this.beingDragged = false;
    		for (i=0; i<targArray.length; i++) {
    			targ = targArray[i];
    			if (eval(this._droptarget) == targ) {
    				this.myFinalX = targ._x;
    				this.myFinalY = targ._y;
    				this.onTarget = true;
    				_root.targ.gotoAndStop(2);
    				break;
    			} else {
    				this.onTarget = false;
    				_root.targ.gotoAndStop(1);
    			}
    		}
    	};
    	//the variables below will store the clips starting position
    	clip.myHomeX = clip._x;
    	clip.myHomeY = clip._y;
    	clip.myFinalX = 0;
    	clip.myFinalY = 0;
    	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)/2;
    			this._y -= (this._y-this.myHomeY)/2;
    			//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) {
    			fonTarget = true;
    			this._x -= (this._x-this.myFinalX)/3;
    			this._y -= (this._y-this.myFinalY)/3;
    		}
    	};
    }
    allTargets = new Array(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30, s31, s32, s33, s34, s35, s36, s37, s38, s39, s40, s41, s42, s43, s44, s45, s46, s47, s48, s49, s50, s51, s52, s53, s54, s55, s56, s57, s58, s59, s60);
    dragSetup(k1, allTargets);
    dragSetup(k2, allTargets);
    reset.onPress = function() {
    	if (fonTarget=true) {
    		this.onTarget = false;
    		k1._x = k1.myHomeX;
    		k1._y = k1.myHomeY;
    		k2._x = k2.myHomeX;
    		k2._y = k2.myHomeY;
    	}
    };
    All those s(N) things are every individual slot on the timeline.

    I know, I know, that whole s(N) thing is very beginner but I didn't know what else to use, and it worked fine.

    But anyways as you can see at the end that is my reset function.

    Please help me!

    Thanks, DC
    Email: Jacktown012@aim.com
    AIM: jacktown012
    MSN: megafire987@hotmail.com

  2. #2
    Back to FK Boards!
    Join Date
    Apr 2006
    Location
    Troy
    Posts
    234
    nevermind i figured it out, thanks guys....
    Email: Jacktown012@aim.com
    AIM: jacktown012
    MSN: megafire987@hotmail.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center