# Calling functions within a class to get the var's in that class

**URL:** <https://forum.kirupa.com/t/calling-functions-within-a-class-to-get-the-vars-in-that-class/144140>\
**Category:** Uncategorized\
**Created:** [April 12, 2005, 2:54am UTC](https://forum.kirupa.com/t/calling-functions-within-a-class-to-get-the-vars-in-that-class/144140 "2005-04-12T02:54:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MTsoul](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@MTsoul](https://forum.kirupa.com/u/MTsoul)\
**Post date:** [April 12, 2005, 2:54am UTC](https://forum.kirupa.com/t/calling-functions-within-a-class-to-get-the-vars-in-that-class/144140/1 "2005-04-12T02:54:20Z")

</div>

Hey all,

Pretty simple question actually.

```auto
class me {
var a:Boolean;
var b:XMLSocket;

function me () {
this.b = new XMLSocket();
this.b.onConnect = this.initiateMe;
this.b.connect(blah blah, blah blah);
}

function initiateMe(success) {
if(success) {
this.a = true;
} else {
this.a = false;
}
}

```

I’m referencing the function initiateMe to the onConnect event handler. When that event handler is triggered, the function initiateMe is triggered as well. However, it doesn’t seem to have the correct parent/child level. I cannot get the variable a within that class anymore. It’s as if the function is called as a public function. “this.a” is not that a variable in that class.

How can I retrieve that variable? What level is this function operating at?

PS. I tried \_parent.parent.a as well, which doesn’t work.

Thanks in advance
