# Beta

**URL:** <https://forum.kirupa.com/t/beta/13563>\
**Category:** flash\
**Created:** [February 14, 2003, 5:58pm UTC](https://forum.kirupa.com/t/beta/13563 "2003-02-14T17:58:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![2t0\_Evenflow](https://avatars.discourse-cdn.com/v4/letter/2/898d66/32.png) [@2t0\_Evenflow](https://forum.kirupa.com/u/2t0_Evenflow)\
**Post date:** [February 14, 2003, 5:58pm UTC](https://forum.kirupa.com/t/beta/13563/1 "2003-02-14T17:58:21Z")

</div>

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

```php
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:

```php
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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 6:33pm UTC](https://forum.kirupa.com/t/beta/13563/2 "2003-02-14T18:33:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 6:54pm UTC](https://forum.kirupa.com/t/beta/13563/3 "2003-02-14T18:54:04Z")

</div>

^What Sen said…lol.

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 7:03pm UTC](https://forum.kirupa.com/t/beta/13563/4 "2003-02-14T19:03:53Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 7:07pm UTC](https://forum.kirupa.com/t/beta/13563/5 "2003-02-14T19:07:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 7:13pm UTC](https://forum.kirupa.com/t/beta/13563/6 "2003-02-14T19:13:38Z")

</div>

its good coding practice…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 14, 2003, 7:39pm UTC](https://forum.kirupa.com/t/beta/13563/7 "2003-02-14T19:39:57Z")

</div>

Ah, thank you guys for clearing that up.
