# Actionscripted easing tween triggered by onrollover

**URL:** <https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883>\
**Category:** Uncategorized\
**Created:** [December 31, 2003, 3:52am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883 "2003-12-31T03:52:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![onData](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ondata/32/395_2.png) [@onData](https://forum.kirupa.com/u/onData)\
**Post date:** [December 31, 2003, 3:52am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/1 "2003-12-31T03:52:40Z")

</div>

Hi,

Just wanted to know if someone could help me out on this one. I have been trying to get a ease tween of a clips \_alpha property to fade in when rolled over, and then fade out when rolled out. In the first frame of the main timeline, I have these two functions:  
[AS]  
this.fadeIn = function(clip) {  
et = 0;  
ed = 10;  
clip.onEnterFrame = function() {  
et++;  
if(et\<ed) {  
clip.\_alpha = Sine.easeIn(et, 0, 100, ed);  
}  
}  
}  
this.fadeOut = function(clip) {  
// the opposite, etc…  
}  
[/AS]  
then within the movieclip that I use as a rollover, I put the following script:  
[AS]  
this.onRollOver = function() {  
\_root.fadeIn(this.faderClip);  
}  
this.onRollOut = function() {  
\_root.fadeOut(this.faderClip);  
}  
[/AS]  
Now, the fading in/out works just fine, but the trigerring is not isolated, and random clips fade in and out regardless of what clip I am moving on or off of. How do I isolate this? These are dynamically attached clips, just as a note. Any help would be greatly appreciated.

CJ:hr:

---

<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:** [December 31, 2003, 4:11am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/2 "2003-12-31T04:11:29Z")

</div>

Try something like this

```auto
step = 10;
MovieClip.prototype.fadeIn = function() {
	this.onEnterFrame = function() {
		if (alpha == 100) {
			delete this.onEnterFrame;
		} else {
			alpha += step;
			this._alpha = alpha;
		}
	};
};
MovieClip.prototype.fadeOut = function() {
	this.onEnterFrame = function() {
		if (alpha == 0) {
			delete this.onEnterFrame;
		} else {
			alpha -= step;
			this._alpha = alpha;
		}
	};
};
mc.onRollOver = fadeIn;
mc.onRollOut = fadeOut;

```

---

<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:** [December 31, 2003, 4:52am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/3 "2003-12-31T04:52:30Z")

</div>

claudio,

thank you somuch, sir. i never really had a good understanding of the MovieClip.prototype feature, and now that I know, I will be using it more often. Btw, I love Sao Paolo! 🍺

Here’s the resulting code:

[AS]  
MovieClip.prototype.fadeIn = function() {  
et = 0;  
ed = 10;  
this.onEnterFrame = function() {  
et++;  
if (et\<ed) {  
this.\_alpha = Sine.easeIn(et, 0, 100, ed);  
}  
};  
};  
MovieClip.prototype.fadeOut = function() {  
et = 0;  
ed = 10;  
this.onEnterFrame = function() {  
et++;  
if (et\<ed) {  
this.\_alpha = Sine.easeIn(et, 100, -200, ed);  
}  
};  
};  
[/AS]

Cheers,  
CJ

---

<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:** [December 31, 2003, 4:54am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/4 "2003-12-31T04:54:56Z")

</div>

Welcome =)

---

<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:** [December 31, 2003, 2:32pm UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/5 "2003-12-31T14:32:15Z")

</div>

Well that script you recommended did work, but it seems to have an effect on one of the other clips in the movie, of which i don’t want to do anything. There is a clip below the one which holds these rollover buttons, and when I roll over them the clip behind it flickers, just in the area of the buttons. I am perplexed. I want to stay away from unscripted tweening because it does not offer the same visual effect that scripted tweening does. I guess I’ll keep working on it.😏

CJ…

---

<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:** [December 31, 2003, 5:29pm UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/6 "2003-12-31T17:29:50Z")

</div>

Why dont you simply use the code i gave you before?

---

<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:** [January 1, 2004, 12:35am UTC](https://forum.kirupa.com/t/actionscripted-easing-tween-triggered-by-onrollover/38883/7 "2004-01-01T00:35:09Z")

</div>

> \*Originally posted by onData \*  
> These are dynamically attached clips, just as a note.

Thus, I can’t just manually reference each dynamically attached movieclip. I am referencing the function from within each attached MC.

Thanks for the response,  
CJ…
