Alpha Fade using a Mouse Over?

Hey everyone. Newbie here. To kirupa.com as well as ActionScripting.

What I’m trying to do is have an object go from 0% and fade to 100% when I move the mouse cursor over it.

For the life of me, I can’t figure out the code to work this. Any help? I’m sure this is the easiest thing on the planet, but I’ve been working with AS for only about a week. :slight_smile:

I’ve made the object a button symbol and given it an instance name of “btRed.” I found the following code in the help file, but it isn’t working. Am I doing something wrong?:

function fadeBlock(event:MouseEvent):void {
btRed.alpha = 1;
btRed.addEventListener(MouseEvent.mouseOver, fadeBlock);
}

how to get rid of it when mouse not over?

careful, I have tested this because I’m actually at work and don’t have Flash CS3, but here is an alternative way to fade, don’t forget to do your imports

ActionScript Code:
[LEFT][COLOR=#000000]**var**[/COLOR] targetAlpha = [COLOR=#000080]1[/COLOR];

[COLOR=#000000]var[/COLOR] easing = .[COLOR=#000080]2[/COLOR];

yourButton.[COLOR=#000080]alpha[/COLOR] = [COLOR=#000080]0[/COLOR];

yourButton.[COLOR=#000080]addEventListener[/COLOR]COLOR=#000000[/COLOR];

[COLOR=#000000]function[/COLOR] btnFadeInCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
evt.[COLOR=#0000FF]target[/COLOR].[COLOR=#000080]alpha[/COLOR] += [COLOR=#000000]([/COLOR]targetAlpha - evt.[COLOR=#0000FF]target[/COLOR].[COLOR=#000080]alpha[/COLOR][COLOR=#000000])[/COLOR] * easing;
[COLOR=#000000]}[/COLOR]
[/LEFT]