# Alpha Fade using a Mouse Over?

**URL:** <https://forum.kirupa.com/t/alpha-fade-using-a-mouse-over/243417>\
**Category:** flash\
**Created:** [November 6, 2007, 8:30pm UTC](https://forum.kirupa.com/t/alpha-fade-using-a-mouse-over/243417 "2007-11-06T20:30:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Awesome\_O\_4000](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Awesome\_O\_4000](https://forum.kirupa.com/u/Awesome_O_4000)\
**Post date:** [November 6, 2007, 8:30pm UTC](https://forum.kirupa.com/t/alpha-fade-using-a-mouse-over/243417/1 "2007-11-06T20:30:54Z")

</div>

Hey everyone. Newbie here. To [kirupa.com](http://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. 🙂

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);  
}

---

<div class="post-metadata">

**Author:** ![cemkocabasa](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cemkocabasa](https://forum.kirupa.com/u/cemkocabasa)\
**Post date:** [May 20, 2008, 4:27pm UTC](https://forum.kirupa.com/t/alpha-fade-using-a-mouse-over/243417/2 "2008-05-20T16:27:27Z")

</div>

how to get rid of it when mouse not over?

---

<div class="post-metadata">

**Author:** ![RebuiltJorge](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@RebuiltJorge](https://forum.kirupa.com/u/RebuiltJorge)\
**Post date:** [May 20, 2008, 5:29pm UTC](https://forum.kirupa.com/t/alpha-fade-using-a-mouse-over/243417/3 "2008-05-20T17:29:45Z")

</div>

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]
