Things You'll Need:
- Flash CS4
-
Step 1
Launch Flash CS4 and create a new ActionScript 3.0 Flash file.
-
Step 2
Draw an object on the stage. I have drawn a rectangle.
-
Step 3
Select the object you drew on the stage and press the F8 button. You will see the "Convert to window" screen appear. Give the object a name, in my case I am calling it Rectangle, make the type "Move Clip" and make sure you check on the box that reads "Export for ActionScript", then click the ok button.
-
Step 4
We now need to give our rectangle object a name. Press CTRL+F3 to display the properties panel as shown in the picture associated with this step. Notice how I gave my movie clip object an instance name called "mcRectangle".
-
Step 5
Click on the first frame in the timeline and then press the F9 key to bring up the action script window.
-
Step 6
In the picture associated with this step, you see the action script code needed to complete this tutorial. So go ahead and copy what it is written.
The first line of code:
mcRectangle.addEventListener(MouseEvent.MOUSE_OVER, mcRectangle_MouseOver)
Creates a mouse over event listener for the object mcRectangle. This says when the mouse cursor moves over mcRectangle then execute the function "mcRectangle_MouseOver".
Lines 2 through handle the actual mouse event fucntion with a paramter of "e". On line 3 we see where we send our output to the trace window. -
Step 7
Run the program by pressing the CTRL+ENTER keys and move your mouse cursor over the object.












Comments
lostmarble said
on 7/21/2009 Thanks Mike. Nice article.