# Fade image in/out scripting (AS2)

**URL:** <https://forum.kirupa.com/t/fade-image-in-out-scripting-as2/293843>\
**Category:** flash\
**Created:** [August 4, 2009, 5:47pm UTC](https://forum.kirupa.com/t/fade-image-in-out-scripting-as2/293843 "2009-08-04T17:47:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorne17](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@lorne17](https://forum.kirupa.com/u/lorne17)\
**Post date:** [August 4, 2009, 5:47pm UTC](https://forum.kirupa.com/t/fade-image-in-out-scripting-as2/293843/1 "2009-08-04T17:47:17Z")

</div>

Hello,

I have successfully coded for my images to load in randomly (thanks to Roalr!) and now I am trying to get the movieclip loader to fade in when a button is rolled over, and fade back out when rolled off.

Can anyone help me out with this script? My issue is my image shows up faded (just how I want) but it doesn’t fade in to 100% when the button is rolled over. It just stays the same 40% as it was when the flash loaded.

I have this on my main frame:

```auto
//Box Fade in Scripts
fadeAmount = 25;

function fadeOut() {
this._alpha -= fadeAmount;
if (this._alpha<=40) {
this._alpha = 40;
this.onEnterFrame = null;
}
}

function fadeIn() {
this._alpha += fadeAmount;
if (this._alpha>=100) {
this._alpha = 100;
this.onEnterFrame = null;
}
}

box_0._alpha = 40;
box_1._alpha = 40;
box_2._alpha = 40;
box_3._alpha = 40;

```

And this on my button (mcbox3):

```auto
on (rollOver) {

_root.box_3 = function() {
_root.box_3.onEnterFrame = fadeIn;
}

}

```

Any ideas?

Thanks,  
Lorne
