# \[FMX\] simple doubt in actionscript

**URL:** <https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311>\
**Category:** Uncategorized\
**Created:** [October 28, 2002, 6:02am UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311 "2002-10-28T06:02:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasarasan](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@rasarasan](https://forum.kirupa.com/u/rasarasan)\
**Post date:** [October 28, 2002, 6:02am UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/1 "2002-10-28T06:02:55Z")

</div>

# Hi folks… I have a movieclip which i want to gradually come into focus(vary the \_alpha value) on mouseover and fade away on mouseout. I am new to actionscript. can anyone help. this is my code assigned for the movieclip… but nothing seems to happen on mouseover.

# on(rollover) { if(this.\_alpha \< 75) { this.\_alpha = 75; } else { this.\_alpha = 0; } } on(rollOut) { this.\_alpha=0; }

pls help me out…  
thanks

---

<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:** [October 28, 2002, 6:08am UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/2 "2002-10-28T06:08:44Z")

</div>

Ok, to make this work you need to apply the button code to a movie clip. Yes, in MX this is luckily possible (I love this feature).

Ok, now you want to apply this code to the movie clip…

```auto
on (rollOver) {
	this.onEnterFrame = function() {
		this._alpha -= 5;
		if (this._alpha<=0) {
			this._alpha = 0;
		}
	};
}
on (rollOut) {
	this.onEnterFrame = function() {
		this._alpha += 5;
		if (this._alpha>=100) {
			this._alpha = 100;
		}
	};
}

```

That tells it that when you rollover the alpha should keep decreasing by 5 until it hits 0.

Then when you rollout the alpha should increase by 5 until it gets back to 100.

Why we did this on a movie clip: The onEnterFrame feature is what allows it to gradually fade. A simple rollOver function would only do the process once everytime you rolled over the button instance.

---

<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:** [October 28, 2002, 6:31am UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/3 "2002-10-28T06:31:19Z")

</div>

Thanks a ton…  
U have been so helpful in many instances…  
Knowing something is different than sharing it to many,…  
and u have been a great source of such stuff…  
pls keep up this good work…

Loving regds:)

---

<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:** [October 28, 2002, 6:43am UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/4 "2002-10-28T06:43:01Z")

</div>

I am glad I could help. I enjoy passing knowledge and helping others.

Thank you for your kind words.

---

<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:** [October 28, 2002, 1:15pm UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/5 "2002-10-28T13:15:09Z")

</div>

Nice code, Lost. But if I may add something… :beam:

```auto
on (rollOver) {
	this.onEnterFrame = function() {
		this._alpha -= 5;
		if (this._alpha<=0) {
			this._alpha = 0;
			delete this.onEnterFrame;
		}
	};
}
on (rollOut) {
	this.onEnterFrame = function() {
		this._alpha += 5;
		if (this._alpha>=100) {
			this._alpha = 100;
			delete this.onEnterFrame;
		}
	};
}

```

pom :cowboy:

---

<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:** [October 28, 2002, 4:52pm UTC](https://forum.kirupa.com/t/fmx-simple-doubt-in-actionscript/7311/6 "2002-10-28T16:52:32Z")

</div>

'DOH!!!

I knew it looked weird.

Thanks Ilyas… greatly appreciated :beam:
