Elementary Institute of Science
Web Design III: Flash

Workshop Home | Introduction | Lesson 1 | Lesson 2 | Lesson 3 | Lesson 4 | Lesson 5

Lesson 6: Mouse-tracking

Tarsier Eye Movement

Download the sample file

3D Tarsier Animation

Download the sample file

Follow the Ball

Type the following text into an new Flash document Actionscript panel:

// Create a ball clip
this.createEmptyMovieClip("ball", 0);
ball.lineStyle(50, 0x0, 100);
ball.moveTo(0, 0);
ball.lineTo(0, 1);
// Animate ball to follow the mouse
ball.onEnterFrame = function( ) {
this._x -= (ball._x - _xmouse) / 4;
this._y -= (ball._y - _ymouse) / 4;
};

Save your file and test it.

UCSD NSF SDSC

© 2006