Article

Home » Design and Layout » Flash Tutorials » Flash Script - Spring Effect

About the Author

SitePoint

View all articles by SitePoint...

Flash Script - Spring Effect

By SitePoint

April 28th, 2003

Reader Rating: 5.5

Download the sample files here.

1. Create any object of your choice, and convert it to a movie clip.

2. Give it an instance name of "child1".

3. Right click the movie clip and insert these actions:

onClipEvent (load)  

{  

spring = false;  

startX = _x;  

startY = _y;  

spX = 0;  

spY = 0;  

}  

onClipEvent (mouseDown)  

{  

startDrag ("", true);  

spring = true;  

}  

onClipEvent (mouseUp)  

{  

stopDrag ();  

spring = false;  

}  

onClipEvent (enterFrame)  

{  

//!spring = if false  

if (!spring)  

{  

//code to create the movements  

spX += (startX-_x);  

spY += (startY-_y);  

spX *= .4;  

spY *= .4;  

_x += spX;  

_y += spY;  

}  

}

5. The script is finished. Press ctrl+enter to test the movie.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: