Jump to content
Sign in to follow this  
atimakula

dragging with ocsillation problem

Recommended Posts

I am trying to drag a movie clip somewhere and then have it dampen ocsillate. I can oscillate, and I can drag and drop, but I can't drop while I have the code allow oscillating. Here's what I put in my MC's action script:

onClipEvent(load){	var ymov = 0;	var ycen = 80;	var xmov = 0;	var xcen = 80;		var k=2; // spring variable	var m=1; // mass	var b=.5; // experimental dampening constant		var a_x=0; // acceleration	var v_x=1; // velocity	var xdiff=1;	var a_y=0; // acceleration	var v_y=1; // velocity	var ydiff=1;		//a+(b/m)*v+(k/m)*x	 (this is the physics function that I used)}on (press) {	startDrag("");}on (release) {	stopDrag();}onClipEvent(enterFrame){	xdiff = xcen-this._x;	a_x = (-(b/m)*v_x - (k/m)*xdiff)/10	v_x += a_x;	this._x -= v_x;		ydiff = ycen-this._y;	a_y = (-(b/m)*v_y - (k/m)*ydiff)/10	v_y += a_y;	this._y -= v_y;}

Share this post


Link to post
Share on other sites

Put the oscillating clip inside another clip that you actually drag. You can drag the parent clip and the child clip should still be able to animate.

Share this post


Link to post
Share on other sites
Put the oscillating clip inside another clip that you actually drag. You can drag the parent clip and the child clip should still be able to animate.
actually i solved this, but I didn't have internet to tell the solution. I ended up just adding an if then in the clip. I would set a variable to tell if it's being dragged or not and had the if then include the ocsillation. That's how I ended up fixing that. But now I pose another problem (another topic: http://w3schools.invisionzone.com/index.php?showtopic=13758). I need to find a way to change the scene or frame on another movie clip, when I move the oscillating movie clip into a square, circle, or past a line. Could someone help me with this? I'll add it to another topic.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...