How to Make a Flash Rollover Image

by David Gitonga

With Flash, it is possible to create crazy effects that match what other programs such as Javascript are capable of doing. Rollover images can be used to create effects on a site, or they can be used as a means to navigate to other sections of a dynamic site. Using ActionScript allows a rollover effect to be more versatile in addition to ensuring that the animation remains small. Only a few lines of script are needed to move an object from state A to B to C.

1

Open a new Actionscript 3.0 Flash file.

2

Import your images. This is done by going to the menu \"File,\" \"Import\" and \"Import to Library.\"

3

Select the timeline and rename “Layer 1” to “Image 1.”

4

Drag an image from the library onto the stage.

5

Convert the image into a symbol. This is done by pressing F8 or going to the menu \"Insert\" and \"New Symbol.\"

6

Name the symbol “Image 1” and check “Movie clip” to convert it into a movie clip.

7

Click \"OK.\" A movie clip with the name “Image 1” appears in the library.

8

Give the movie clip an instance name “Image1_mc.\" Do this under the “Properties” panel located below the stage under the “Properties” tab.

9

Select the 30th frame on the timeline and hit F5 to add a frame.

10

Create animation by right-clicking anywhere between frame 1 and 30 and selecting “Create Motion Tween.\"

11

Select frame 30.

12

Select the image on stage and change its Alpha setting to 0 percent by going to the “Properties” tab under “Color.” The image on stage is now invisible.

13

Lock the “Image 1” layer and insert a new layer “Image 2.” Use the “Lock/Unlock All Layers” icon above the layers.

14

Select frame 55 of the “Image 2” layer and hit F5.

15

Select frame 25 and hit F6. This inserts a key frame onto the selected frame.

16

Drag “Image 2” onto the stage and press F8.

17

Select \"Movie clip\" and give it an instance name of “Image2_mc.\"

18

Create a motion tween between frame 25 and 55.

19

Select frame 25 and the image on stage and change the Alpha setting to 0 percent.

20

Select frame 30 and the image on stage and give it an Alpha setting of 100 percent.

21

Select frame 55 and the image on stage and set the Alpha setting to 0 percent.

22

Repeat the above steps for more images added. Insert a new layer named “Actions” and press F6 on frame 30 and 55 to add key frames.

23

Click on frame 1 of the “Actions” layer and press F9 to add the following code:<br />stop()<br />GO<br />image1_mc.addEventListener(MouseEvent.MOUSE_OVER,imageOver)<br />GO<br />function imageOver(event:MouseEvent):void {<br />play()<br />GO<br />}

24

Select frame 30 of the “Actions” layer and enter the code below:<br />stop()<br />GO<br />image2_mc.addEventListener(MouseEvent.MOUSE_OVER,imageOver2)<br />GO<br />function imageOver2(event:MouseEvent):void {<br />play()<br />GO<br />}<br /><br />Select frame 55 and under the Actions layer insert this line of code:<br />Stop();

25

Test the movie by pressing “Ctrl + Enter.” Your image rollover effect should now work.<br />Publish the animation by going to \"File\" and \"Publish.\"

Tip

  • check You can have as many objects as possible sliding in and out. Use graphics, input text and buttons embedded in the movie clip symbol to create dynamic animations.

Items you will need

About the Author

David Gitonga is a Web designer and has an associate degree in information technology and electronics. He has more than two years of experience in Web design and writing Web content and more than five years of experience in electronics. He has written a number of articles for various websites.

Photo Credits

  • photo_camera Jupiterimages/Photos.com/Getty Images