About a month ago, someone posted this FLA. It is just a simple thing to give example of animated button (where the animation still happens even if you roll your mouse out early). It works, this is not a problem of the code.
They even went so far as to write some descriptions of what was happening along the way. I am able to follow along 95% of the way, but not 100%. And, I do want to actually learn this and not just copy paste it into other applications. So, I am hoping that someone can take just a minute and dive in a little deeper with the explanations to help me better understand it.
Specifically:
Line 13: 2 questions - what does “this” refer to? and which frame is it referrign to related to the onEnterFrame?
Lines 18-19: Still not really sure what this does or why? I think its meant to stop the action, but isnt that what the stop() inside the related MC does?
I have attached the FLA just in case you need it to follow along better. But, here is the main timeline actions:
// browse through everything in the movieclip
for (all in this) {
/* only use the instances of a button of which
the name begins with "btn",
so basically only use our menu buttons */
if (this[all] instanceof Button && this[all]._name.substr(0, 3) == "btn") {
/* set onRollOver handler for the buttons to make the
animation move forward when rolled over */
this[all].onRollOver = function() {
/* set the onEnterFrame handler for the movieclip
mc+ the number of the current button,
so for btn1 mc1 and for btn2 mc2 ... */
this._parent["mc"+this._name.substr(3, 1)].onEnterFrame = function() {
// make it go to the next frame
this.nextFrame();
/* if the current frame is the last frame,
delete the onEnterFrame handler */
if (this._currentframe == 16) {
delete this.onEnterFrame;
}
};
};
/* set onRollOut handler for the buttons to make the
animation move backwards when rolled out */
this[all].onRollOut = function() {
this._parent["mc"+this._name.substr(3, 1)].onEnterFrame = function() {
this.nextFrame();
if (this._currentframe == 2) {
delete this.onEnterFrame;
}
};
};
}
}
Thanks for your time.