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)

Move the object

28.11.2006, 22:45    Total views: 51687

See how to move any object in flash 8 using the Action Script and cursor.



Step 1

Create a new flash document, choose Modify > Document (Ctrl+J), and set Width to 350 and Height to 250px.



Step 2


Double click on layer1 to rename its name in background. Then, insert a new layer and name it object.

Step 3

Take the Rectangle Tool (R), and draw a "rectangle" which will represent the "object". See the picture below.



Step 4

While your "object" is still selected, press F8 key (Convert to Symbol), and convert it into a Movie Clip.



Step 5

Double click on a new made Movie Clip, or choose right click and Edit in Place.

Step 6

Then, while your object is still selected, press again F8 key and convert it into a Button symbol.



Step 7

While your object is still selected, open the Action Script Panel (F9), and paste this script:

on (press) {
swapDepths(2 );
_root.cursor.swapDepths(3);
startDrag("");
}

on (release) {
stopDrag();
}

Step 8

Go back on the main scene (Scene1), click on the first frame of layer object, and in Action Script Panel, paste this script:

help = false;

Step 9

Duplicate your "object" few times if you like.

Step 10

Insert a new layer and name it cursor. Then, take the Text Tool (T), and type out of background "Move it". See the picture below.





Step 11

While your text (cursor) is still selected, press F8 key and convert it into a Movie Clip.



Step 12

After that, open the Properties Panel (Ctrl+F3), and under <Instance Name> type cursor.



Step 13

Then, select again the cursor, open the Action Script Panel (F9), and paste this script:

onClipEvent (load) {
}
onClipEvent (mouseMove) {
xm = getProperty (_root, _xmouse );
ym = getProperty (_root, _ymouse );
setProperty("_root.cursor", _x, xm);
setProperty("_root.cursor", _y, ym);
}

onClipEvent (mouseDown) {
with (_root.cursor) {
gotoAndStop("clench");
}
}

onClipEvent (mouseUp) {
with (_root.cursor) {
gotoAndStop("open");
}
}

We're done!

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: 221536

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