# Scope of 'this' operator

**URL:** https://forum.kirupa.com/t/scope-of-this-operator/150260
**Category:** Uncategorized
**Created:** [June 6, 2005, 11:03am UTC](https://forum.kirupa.com/t/scope-of-this-operator/150260 "2005-06-06T11:03:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![prakaz](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@prakaz](https://forum.kirupa.com/u/prakaz)
#### Post date: [June 6, 2005, 11:03am UTC](https://forum.kirupa.com/t/scope-of-this-operator/150260/1 "2005-06-06T11:03:11Z")

</div>

hello i have a class which stores the mouse x and y positions. i m having problem in accessing the variables of the class from the events inside the class

[color=#878787]// controller.as  
[/color]class controller{  
public [color=#000087]var[/color] x:[color=#000087]Number[/color];  
public [color=#000087]var[/color] y:[color=#000087]Number[/color];  
public [color=#000087]var[/color] mouse\_listener:[color=#000087]Object[/color]=[color=#000087]new[/color] [color=#000087]Object/color;

public [color=#000087]function[/color] controller(){ [color=#878787]// constructor  
[/color]mouse\_listener.[color=#000087]onMouseMove[/color]=[color=#000087]function/color{  
[color=#000087]this[/color].x=[color=#000087]\_root[/color].[color=#000087]\_xmouse[/color];  
[color=#000087]this[/color].y=[color=#000087]\_root[/color].[color=#000087]\_ymouse[/color];  
}  
[color=#000087]Mouse[/color].[color=#000087]addListener/color;  
}  
}

[color=#878787]// code for controller.fla  
[/color][color=#000087]var[/color] c:controller=[color=#000087]new[/color] controller();

[color=#000087]\_root[/color].[color=#000087]onMouseDown[/color]=[color=#000087]function/color{  
[color=#000087]trace/color;  
}

[color=#878787]//outputs “undefined undefined” whenever the mouse is clicked on stage  
[/color]

my problem here is i am not able to access the variables x and y of the controller class. when i try to access them from the constructor the this.x and this.y seems to refer to the mouse\_listener object. i am not able to update the values to the x,y variables of the class. how do i do this ?

help please !!
