atimakula Posted June 19, 2007 Share Posted June 19, 2007 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;} Link to comment Share on other sites More sharing options...
justsomeguy Posted June 21, 2007 Share Posted June 21, 2007 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. Link to comment Share on other sites More sharing options...
atimakula Posted June 26, 2007 Author Share Posted June 26, 2007 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.