# \[AS2\] Reffering to this from function defined inside class

**URL:** <https://forum.kirupa.com/t/as2-reffering-to-this-from-function-defined-inside-class/175855>\
**Category:** flash\
**Created:** [January 18, 2006, 11:51am UTC](https://forum.kirupa.com/t/as2-reffering-to-this-from-function-defined-inside-class/175855 "2006-01-18T11:51:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![virusescu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@virusescu](https://forum.kirupa.com/u/virusescu)\
**Post date:** [January 18, 2006, 11:51am UTC](https://forum.kirupa.com/t/as2-reffering-to-this-from-function-defined-inside-class/175855/1 "2006-01-18T11:51:02Z")

</div>

Hello fellow kirupians. Time for me again to ask for you help.  
I’ll begin with the example code

```auto

class className () {
    //constructor
    function className(targetmc,linkId) {
      xxx = targetmc.attachMovie(linkId,targetmc.getNextHighestDepth());
      xxx.onPress = function () {
          // this here refers to the newly created mc.
         this.startDrag();
         intvl = setInterval(updater,200); // this doesnt work
         // nor does the flowing because this reffers to the mc I press not to the instace of the class
         intvl = setInterval(this.updater,200);
      }
    }
    private function updater() {
        trace("Updating + "+getTimer())
    }
}

```

My question is how can I set up an interval when I click on a button that is created from within the class.  
I need my function updater to keep repeating untill I clear the interval. The only way I can figure out is to give the full path like  
this.\_parent.\_parent.instanceName.updater inside the setInterval, but although this works I think is just dumb to hardcode the instace name of the class. I could of course try to pass the instance name as a parameter, but I would really love to find out the smart way to do this (by the book).

Thank you for taking your time and reading this.
