Our first example shows you how to make a photo appear and disappear using the mouse. When you're moving your mouse near the photo, the photo will become more and more clear - slowly appearing... and when you're moving your mouse cursor off the photo, the photo will slowly disappear. To make this project, you have to use action script code. Let's take a look at how to add code to a Flash scene.
First: Look at our goal: Move your mouse over the rectangle!





for (i=4; i<6; i++) {
_root.attachMovie("circle","circle"+i,i);
_root["circle"+i]._x = (65*(i-4)) + 40;
_root["circle"+i]._y = 100;
}
for (i=6; i<12; i++) {
_root.attachMovie("circle","circle"+i,i);
_root["circle"+i]._x = (65*(i-6)) + 40;
_root["circle"+i]._y = 200;
}
Step 8
Double-click on the movie clip on stage with the Selection tool(V). You should now be inside the Movie Clip.
Step 9
Move now, photo1_mc movie clip from the Library on the Stage using the mouse and place it on the position like it is shown on the picture below.
Step 10
Take the Selection Tool (V) and right-mouse click once on that movie clip that you just dragged from the libray on the stage and choose Actions from the pop-up menu to go to the Action Script panel again. Then, enter the following code inside the actions panel:
onClipEvent (enterFrame) {
xdist = Math.round(_root._xmouse - _parent._x);
ydist = Math.round(_root._ymouse - _parent._y);
distancefromthis = Math.round(Math.sqrt((xdist*xdist) + (ydist*ydist)));
_parent._alpha = (95-distancefromthis)+18;
}
Go back on the main scene and test your Movie (Command+Enter).
Have a nice day!
Right-mouse click on me to download this example.
To try an example, download the Flash File (*.fla) in your Flash Editor.
Use the Command-Enter shortcut to Publish the file as a Shockwave file (*.swf).
Put the Shockwave file in the same directory as your HTML.
It should then run like the Binary Dice example.