Flash tutorials
Home 3D (2) Actionscripting (65) Animation (100) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (52) Text Effects (38)

Circle follow the mouse click

1.7.2009, 18:8    Total views: 10755

This, step by step, detailed action script lesson, will show you how to create that every object follow the mouse click. For this example I will use circle as object. You can use this action script lesson for some presentation. Let's start!


Example:

Click somewhere on photo to see the object!



Step 1

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 32 and click ok.



Step 2


Using the flash tools for drawing, draw any object which you like to use for this lesson.

Step 3

While the object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 4

Select now the Selection Tool (V) and click once on the object to select it. After that, go to the AS panel (F9) and enter this code inside the actions panel:

onClipEvent (load) {
 _x = 0;
 _y = 0;
 speed = 8;
}
onClipEvent (mouseDown) {
 endX = _root._xmouse;
 endY = _root._ymouse;
}
onClipEvent (enterFrame) {
 _x += (endX-_x)/speed;
 _y += (endY-_y)/speed;
}

We're done!

Test your movie and enjoy!

Download source file (.fla)

Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 221535

2. Water effect
Total views: 166040

3. Photo slide show
Total views: 153641

4. High-tech city animation
Total views: 151459

5. Special Picture Effect
Total views: 146246

Related links