Toxiclab.org

Push the object away

4.11.2006, 18:58
Submited in: Flash | Total Views: 62076

Tutorial shows you how to push the object away using the Action Script in flash 8. You will also learn how to convert that object into a Movie Clip Symbol, how to use Action Script Panel and more.



Step 1

Create a new flash document, and choose Modify > Document (Ctrl+J) and set Width to 300 and Height to 250px. Frame rate set to 70fps (Frames per Second).





Step 2


Create, or Import any object, and convert it into a Moive Clip.





Step 3

Double click on a new made Movie Clip (object) to go in its inside.

Step 4

After that insert a new layer and name it action.

Step 5

Click on frame 1 of layer action, open the Action Script Panel (F9), and paste this script:

x00 = _x;
y00 = _y;
MAAI = 400;

Step 6

Click on frame 2, press F6 key, open the Action Script Panel (F9), and paste this script:


x0=_x
y0=_y
x=_root._xmouse
y=_root._ymouse
a=x-x0
b=y-y0
r=Math.sqrt(a*a+b*b)

quer_fugir_x=this._x-(a/r)*MAAI/r
quer_fugir_y=this._y-(b/r)*MAAI/r

quer_voltar_x=(x00-x0)/2
quer_voltar_y=(y00-y0)/2

this._x=quer_fugir_x+quer_voltar_x
this._y=quer_fugir_y+quer_voltar_y

Step 7

Click on frame 3, press F6 key, and paste this script:

gotoAndPlay(2);

Step 8

Click on frame 3 of layer 1 and press F5.



Step 9

Go back on the main scene (Scene1), and duplicate your object few times.

We're done!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials