# This referance to listener object

**URL:** <https://forum.kirupa.com/t/this-referance-to-listener-object/275565>\
**Category:** Uncategorized\
**Created:** [November 16, 2008, 12:07am UTC](https://forum.kirupa.com/t/this-referance-to-listener-object/275565 "2008-11-16T00:07:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![afraidofdark](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@afraidofdark](https://forum.kirupa.com/u/afraidofdark)\
**Post date:** [November 16, 2008, 12:07am UTC](https://forum.kirupa.com/t/this-referance-to-listener-object/275565/1 "2008-11-16T00:07:55Z")

</div>

hello

class Ingredient  
{  
private var fx:Number = 0;  
private var fy:Number = 0;  
private var \_slot:Slot;  
private var \_mcIngred:MovieClip;  
private var me:Ingredient;

public function Ingredient(sName:String,sNewName:String,slot:Slot)  
{  
me = this;  
\_slot = slot;  
\_mcIngred =\_root.attachMovie(sName,sNewName,\_root.getNextHighestDepth());  
\_mcIngred.\_x = \_slot.getSlotMc().\_x;  
\_mcIngred.\_y = \_slot.getSlotMc().\_y;

var mouseListener:Object = new Object();

var f:Boolean = false;

mouseListener.onMouseDown = function():Void  
{  
[COLOR=darkred]//\_root[sNewName] refers to \_mcIngred but I cant use \_mcIngred[/COLOR]  
[COLOR=#8b0000]// instead of \_mcIngred I have to use \_root[“what ever the movieclip name is”][/COLOR]  
[COLOR=darkred]// if I try to use \_mcIngred , It behave as if it is undefined[/COLOR]  
[COLOR=darkred]// actually here in this block “this” refers to listener object which is mouseListener[/COLOR]  
[COLOR=darkred]// how can I refer to the class, and what is the reason of this[/COLOR]  
[COLOR=darkred]// thank you for your help[/COLOR]  
if(\_root[sNewName].hitTest(\_xmouse,\_ymouse,true))  
{  
\_root[sNewName].startDrag();  
f = true;  
fx = \_root[sNewName].\_x;  
fy = \_root[sNewName].\_y;  
}  
}  
…snip
