Actionscripted easing tween triggered by onrollover

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:

Try something like this

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;

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! :beer:

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

Welcome =)

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.:smirk:

CJ…

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

*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…