# Gradual alpha Movie Clip

**URL:** <https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251>\
**Category:** flash\
**Created:** [March 12, 2003, 4:46am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251 "2003-03-12T04:46:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucidsurf](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@lucidsurf](https://forum.kirupa.com/u/lucidsurf)\
**Post date:** [March 12, 2003, 4:46am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/1 "2003-03-12T04:46:18Z")

</div>

Hey there guys… a quick (and undoubtedly simple) problem…

I have a button that, when rolled over, causes a certain movie clip to fade out. Then, on roll out, it fades back in (to 50% opacity). The code looks like this:

on (rollOver) {  
setProperty(“mc1”, \_alpha, “0”);  
}  
on (rollOut) {  
setProperty(“mc1”, \_alpha, “50”);  
}

Can anyone suggest a way to make it fade out and in **gradually**?

Thanks!  
Brad

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 5:05am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/2 "2003-03-12T05:05:48Z")

</div>

Try something like this using hitTest. Just give your movieclip an instance name of something like “box” for example and apply this script to your button:

```php
onClipEvent (enterFrame) {
	if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
		_root.box._alpha -= 10;
	} else {
		_root.box._alpha += 10;
	}
}

```

I attached a sameple FLA as well. =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 5:10am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/3 "2003-03-12T05:10:33Z")

</div>

Howdy…

Same thing as electrongeek did… (A couple of minutes late… :() I would normally delete this, but mine goes with FMX syntax, so check out the difference… There shouldn’t be no actual difference between mine and his… Just check out how the syntax can be different…

```php
mc1._alpha = 50;
mc1.speed = 5;
mc1.onRollOver = function ()
{
	this.onEnterFrame = function ()
	{
		if (this._alpha < 100)
			this._alpha += mc1.speed;
		else
		{
			this._alpha = 100;
			delete this.onEnterFrame;
		}
	}
}

mc1.onRollOut = function ()
{
	this.onEnterFrame = function ()
	{
		if (this._alpha > 50)
			this._alpha -= mc1.speed;
		else
		{
			this._alpha = 50;
			delete this.onEnterFrame;
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 5:41am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/4 "2003-03-12T05:41:02Z")

</div>

Thank you both electronicgeek & CyanBlue. Both answers were very helpful and so were the files.

One last thing…  
CyanBlue, in your download I can see that there is an Action attached to frame 1 of layer MC - but I can’t find the actual script :\*( . Therefore, when I insert the code into my file (on a layer named "actions’) the ‘mc1’ instance of my movieclip is not changing. Should I have mentioned that this ‘mc1’ instance of my movieclip is within about 3 levels of parent movieclips?:hangover:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 5:43am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/5 "2003-03-12T05:43:40Z")

</div>

Sorry, please disregard my above script question. I understand now! Thanks again! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 6:27am UTC](https://forum.kirupa.com/t/gradual-alpha-movie-clip/15251/6 "2003-03-12T06:27:11Z")

</div>

😉
