Flashvault.net

Move the object

28.11.2006, 22:45    Total views: 32707

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!

Forum - Newest Discussions

Interactivity with mouse coordinates
Last post by: flip76
Date: 29.12.2008 19:14:53

Interactivity with mouse coordinates
Last post by: flip76
Date: 29.12.2008 18:27:44

Hi everybody
Last post by: Admin
Date: 22.12.2008 12:15:28

How do I combine images with text simultanuelsy?
Last post by: speedyj
Date: 03.12.2008 23:10:49

photogallery
Last post by: trnghosn
Date: 26.11.2008 16:22:19

Regarding the Gradient by Mouse Tutorial...
Last post by: cloudy-days
Date: 19.11.2008 07:41:03

Open flash cs3 fla in flash 8???
Last post by: benjezza
Date: 14.11.2008 23:41:46

flash form tutorial
Last post by: bukopie79
Date: 12.11.2008 07:56:46

Flash form with PHP and Postgre
Last post by: bukopie79
Date: 07.11.2008 04:23:06

Related links