Beta

Here is the code you provided last night for the drop down menu:

onClipEvent (enterFrame) {
	if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
		this.play();
		if (this._currentframe == 10) {
			stop();
		}
	} else if (this._currentframe>=10) {
		play();
	}
}

I went through and took away every the code “this” every where’s in the script, so thus I had this:

onClipEvent (enterFrame) {
	if (hitTest(_root._xmouse, _root._ymouse, true)) {
		play();
		if (_currentframe == 10) {
			stop();
		}
	} else if (_currentframe>=10) {
		play();
	}
}

The menu worked the same, so, in spite of learning more, why did you add “this” in those places?

whos you?

What this does is refer to the current object which you are in - or where the code is being put, which is typically implied when you’re writing code for the object youre in. This is of course unless you are within an object function (method), which is often the case with Flash MX when you write something like

myMovie.onEnterFrame = function(){
_x += 10;
}

because no this is used there, the _x refers to the current movieclip where the code is being placed, which is the timeline that myMovie exists, or myMovie._parent. However, there you would want the _x to reference the myMovie or the movieclip associated with that onEnterFrane method. That is where the this is needed to reference the this of the object.

When ON a movieclip adding onClipEvent events, the this is implied because you are actually IN that movieclip. However, this is sometimes still used there because of how it would be used in an onEnterFrame event like in above

^What Sen said…lol.

You don’t need to use “this” when in an onClipEvent, but I do it out of habit.

there are some cases when you need to use this… like for duplicated movieclips “onenterFrame” actions… if you don’t use “this” then the whole code goes crazy…

Yeah, I use prototypes a lot, and I tend to need to use “this” with them or they go berzerk.

So it is just a habit for me to do it all the time whether I need to or not.

its good coding practice…

Ah, thank you guys for clearing that up.