How would I simplify this code so I don’t keep repeating the onEnterFrame functions for each movieclip? (or can I?)
function simpleFade() {
clearInterval(simpleFadeInterval);
ground.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha<0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
alone.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha<0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
top.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha<0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
crack.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha<0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
roots.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha<0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
}
simpleFadeInterval = setInterval(simpleFade, 2000);
can’t you just create a prototype function on the main timeline and call it when you need it?
Yes, probably but for me to take the time to figure that out is not really worth it, although I do appreciate the suggestion.
I was really just looking for suggestions that I could learn from, so maybe when I have some spare time I will look into that- thank you =)
var stuff:Array = new Array(ground, alone, top, crack, roots);
simpleFadeInterval = setInterval(simpleFade, 2000);
function simpleFade() {
clearInterval(simpleFadeInterval);
for (var i:Number = 0; i < stuff.length; i++) {
stuff*.onEnterFrame = function():Void {
this._alpha -= 25;
if (this._alpha <= 0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
}
}
Just add all of the movie clips you want to fade to the stuff array 
Assuming the code is on the same timeline that addresses the movieclips, otherwise you’ll have to put the path into the array as well right?
Whew! Wasn’t sure I had that right. Thanks. :pleased:
Thanks to both of you, I appreciate the input. I probably should have though of using an array on my own…:h: But that’s easy to see now that you have posted.
=)