Mouse Tracking - 08MouseTracking.flaThis example keeps track of the mouse position. This is useful for games and drawing graphics. It also introduces some new Flash Movie concepts. The movie has three frames. In frame one, the mouse position is displayed and if the mouse is in the top left corner, the movie jumps to frame three and stops. Here is the code for frame one.
The movie is set to play at twelve frames per second so it jumps to frame two almost immetiately. Frame two has one line of code telling the movie to jump back to frame one. This loop runs continuously at twelve frames per second. Each time the movie plays frame one, the mouse position is displayed. The mouse position is also tested to see if the movie should jump to frame three.
Frame three contains a button with this code attached to it. If the button is pressed, the movie jumps back to frame one and restarts.
Here is the movie.
Here is the downloadable source code.
|
|||
|
|||
Set up your Flash MX environment like this ...
|
|||
Here is the example movie. The mouse X and Y positions are displayed.
You can download the source code. |
|||
TaskLearn the techniques of working with more than one movie frame and be able to re-create this movie without notes. (not easy). |
© C N Bauers (2004) - You may use these materials for your self education. Educational institutions may use these materials too.