Macromedia Flash - Push objects away from the cursor

This tutorial will show you how to make a flash file with the effect of pushing the object away from the cursor by using some Action Script fragments in Flash 8. Let's look at the following example file.

Step 1

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

Macromedia Flash - Push objects away from the cursor Picture 1

Step 2

Create or Import ( Ctrl + R ) any object and convert it into a Movie Clip

Macromedia Flash - Push objects away from the cursor Picture 2

Macromedia Flash - Push objects away from the cursor Picture 3

Step 3

Double-click the newly created Movie Clip (opject) to enter the edit object

Step 4

Then add a new layer and name it action.

Step 5

Select frame 1 of layer action, open the Action Script Panel (F9) and include the following code:

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

Step 6

Select frame 2, press F6 key to open the Action Script Panel (F9) and enter the following code:

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

Select frame 3, press F6 key and enter the following script:

gotoAndPlay (2);

Step 8

Select frame 3 of layer 1 and press F5

Macromedia Flash - Push objects away from the cursor Picture 4

Step 9

Return to the main scene (Scene 1), multiply the object several times and place it in the corresponding positions as in the example above.

Download the example file.

4 ★ | 1 Vote

May be interested

  • Photoshop CS: Curved image on the backgroundPhoto of Photoshop CS: Curved image on the background
    in a recent exercise, i showed you how to create artistic borders and frames for an image. do you think those photos will look softer and more impressive when it is modified a bit to become a curved image?
  • Macromedia Flash - Photo effects appear with soundPhoto of Macromedia Flash - Photo effects appear with sound
    with this exercise, you will know how to create an attractive appearance of the image object along with the sound in flash 8 (without using the action scrip)
  • Photoshop CS: Grid line systemPhoto of Photoshop CS: Grid line system
    this practical exercise shows you how to use some of the features in the filter filter to create an abstract graphic, a cube with vertical and horizontal lines that have the same attraction as a matrix. after this exercise, you can apply
  • Macromedia Flash - Digital clockPhoto of Macromedia Flash - Digital clock
    time is money and we must always know how to hold it. this article will show you how to create a digital clock effect with the current date using flash 8.
  • Macromedia Flash - Zoom in / Zoom out with the buttonPhoto of Macromedia Flash - Zoom in / Zoom out with the button
    this exercise will show you how to create a zoomed in and out movie clip using the buttons and action script in flash 8.
  • Macromedia Flash - Create text frames with scroll bars in Flash 8.0Photo of Macromedia Flash - Create text frames with scroll bars in Flash 8.0
    a text frame with scroll bar if you create it in html is too simple and normal. just a little basic knowledge, a little graphic aesthetic, you can completely create a text frame with a nice scroll bar with flahs 8 as a guide to this article.