Trying to grasp applying generic function to mc onEnterFrame's

Ok, so first of all thank you for reading this, extra thanks for taking the time to reply.

So, I’m a beginning to intermediate Flash and AS guy grappling with some programming concepts.

I find that when I create my own functions from scratch, especially to define a generic function to different movie clips, in this case to their onEnterFrame functions, I get unexpected results.

The bottom is some code from a new simple website I’m trying to code. My problem is that I can’t get the function working in a generic way. I know I may be taking the completely wrong approach and totally missing something, but I am continuously coming up with problems (seems to be a misunderstading of scope at a deeper level, not simple variable timeline scope, but inherant scope within functions, etc…).

So, I will just copy paste the code here and try and comment as much as possible. For claritie’s sake I will remove button codes except option1 and option2.

Ok, it’s late and my brain is fried. Here we go. Flame away, I need to get this!!

//initialization of a few global and one timeline variable. These should
//be self explanatory in the code so I wont go into to much detail
//my probs arent in the detail but in the overall relationship of the
//code blocks
//
_global.INIT_MOVIE_POS = 1230;
_global.TARGET_X = 5;
_global.SPEED = 5;
var currentMovie = “0”;
//
//
//LoadNewMovie function unloads current movie and loads new movie
//My main problem here is that this function seems to assign itself to
//every movie clip onEnterFrame that is subscribed to it, even though
//the assignment of the MC’s onEnterFrame is governed by a onRelease
//event of the associated button
//
//
LoadNewMovie = function () {
if (currentMovie != “0”) {
currentMovie.UnloadMovie();
}
this._visible = true;
if (this._x>TARGET_X) {
this._x -= (TARGET_X+this._x)/5;
} else {
this._x = TARGET_X;
currentMovie = this;
delete this.onEnterFrame;
}
};
//
//
//UnloadMovie unloads the current movie, called by LoadNewMovie
//
UnloadMovie = function() {
currentMovie._visible = false;
currentMovie._x = INIT_MOVIE_POS;
};
//prototype shiver controls roll over and roll out movement of buttons
//
MovieClip.prototype.shiver = function(xScale, yScale, strength, weight) {
var xScaleStep = 0;
var yScaleStep = 0;
this.onEnterFrame = function() {
xScaleStep = (xScale-this._xscale)strength+xScaleStepweight;
yScaleStep = (yScale-this._yscale)strength+yScaleStepweight;
this._xscale += xScaleStep;
this._yscale += yScaleStep;
};
};
option1.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option1.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option1.onMouseDown = function() {
_root.accolade_mc.onEnterFrame = LoadNewMovie;
};
option2.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option2.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option2.onMouseDown = function() {
dummy2_mc.onEnterFrame = LoadNewMovie;
};

Any and all help is appreciate here. Sometimes advanced RIA developers will see a problem like this and send me a 5 page RIA app that explains all the problems, but is SO over my head, it doesn’t really help. What I do need to understand is, from a procedural approach to my simple problem, what am I missing, OR if my problem naturally points to an OOP approach of solving it, please let me know what the area of my fundamental misunderstanding or lack of knowledge is so I can specifically look to address it.

I am prepairing to study OOP structure, but feel that it won’t benefit me until I have a strong procedural background. + I’m in between jobs right now and have to think about immediate visual effects, nor RIA which I am still a bit far from to say the least!

Anybody who read this far, you have my serious appreciation, respect, and thanks!!

David

:?)